如何在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)
热门推荐
4 初八的祝福语简短
10 讲课祝福语简短10字
11 2026年祝福语大全简短
12 双十一祝福语大全简短
13 老婆生日祝福语短句简短
14 哥哥祝福语简短霸气句子
15 老师节祝福语的简短
16 古风中考祝福语简短
17 鱼的内涵简短祝福语
18 恋爱祝福语大全简短搞笑