如何在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 高考祝福语 简短12字
13 上司生日祝福语简短 女性
14 恋爱祝福语大全简短搞笑
15 婚礼祝福语简短情话文案
16 入学校简短祝福语
17 写给兄弟的祝福语简短
18 送花祝福语简短十一朵