如何在MySQL表的列中自动插入当前日期?
借助CURDATE()和NOW()函数,我们可以自动将当前日期插入MySQL表的列中。
示例
假设我们要在表year_test的OrderDate列中自动插入当前日期,下面的查询将执行此操作-
mysql> Insert into year_testing (OrderDate) Values(CURDATE()); mysql> Select * from year_testing; +------------+ | OrderDate | +------------+ | 2017-10-28 | +------------+ 1 row in set (0.00 sec) mysql> Insert into year_testing (OrderDate) Values(NOW()); mysql> Select * from year_testing; +------------+ | OrderDate | +------------+ | 2017-10-28 | | 2017-10-28 | +------------+ 2 rows in set (0.00 sec)
热门推荐
10 职场祝福语大全 简短精辟
11 相恋人回去祝福语简短
12 婚庆花篮祝福语简短大气
13 整形机构开业祝福语简短
14 师傅退休蛋糕祝福语简短
15 生日贺卡祝福语 简短独特
16 祝福语诗意文案简短
17 写给男生简短的祝福语
18 法考面试祝福语简短