current_timestamp 函数可以用来获取当前时间,默认是年月日时分秒。可以用1~6作为参数,此时会展示毫秒,参数代表微妙时间的精度。
功能和 now()函数(MySQL:now() 函数) 相同。
mysql> select current_timestamp()
+---------------------+
| current_timestamp() |
+---------------------+
| 2020-04-11 12:54:56 |
+---------------------+
mysql> select current_timestamp(0)
+----------------------+
| current_timestamp(0) |
+----------------------+
| 2020-04-11 12:54:59 |
+----------------------+
mysql> select current_timestamp(1)
+----------------------------+
| current_timestamp(1) |
+----------------------------+
| 2020-04-11 12:55:01.800000 |
+----------------------------+
mysql> select current_timestamp(6)
+----------------------------+
| current_timestamp(6) |
+----------------------------+
| 2020-04-11 12:55:04.928047 |
+----------------------------+
mysql> select current_timestamp(10)
(1426, u"Too big precision 10 specified for column 'now'. Maximum is 6.")