now() 函数可以用来获取当前时间,可以用1~6作为参数,此时会展示毫秒,参数代表微妙时间的精度。
示例:
mysql> select now()
+---------------------+
| now() |
+---------------------+
| 2020-04-11 11:22:06 |
+---------------------+
可以用1~6作为参数,用于展示微妙时间的精度。
mysql> select now(0)
+---------------------+
| now(0) |
+---------------------+
| 2020-04-11 11:24:30 |
+---------------------+
mysql> select now(1)
+----------------------------+
| now(1) |
+----------------------------+
| 2020-04-11 11:24:32.700000 |
+----------------------------+
mysql> select now(2)
+----------------------------+
| now(2) |
+----------------------------+
| 2020-04-11 11:24:35.830000 |
+----------------------------+
mysql> select now(3)
+----------------------------+
| now(3) |
+----------------------------+
| 2020-04-11 11:24:39.487000 |
+----------------------------+
mysql> select now(6)
+----------------------------+
| now(6) |
+----------------------------+
| 2020-04-11 11:26:09.886000 |
+----------------------------+
mysql> select now(7)
(1426, u"Too big precision 7 specified for column 'now'. Maximum is 6.")