Mysql function to generate millisecond timestamp as BIGINT (13)

I know mysql does not support storing timestamp columns with millisecond .

My question is: is there a mysql function that I could write that will output the current time as the BIGINT (13) value in millisecond.

For example, since now () prints a timestamp:

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2010-10-27 11:24:23 |
+---------------------+

I would like to write a mysql function, for example ts (), which outputs bigint (13), for example.

mysql> select ts();
+---------------------+
| ts()               |
+---------------------+
| 1288172185517      |
+---------------------+

My reasons for this is being able to populate the default value for a column with the value of the ts () function

e..g

`MY_TIMESTAMP_COLUMN` BIGINT(13) DEFAULT ts(),
+3
source share
1 answer

, , :

http://bugs.mysql.com/bug.php?id=8523

sprinf tv.tv_sec * 1000000 + tv.tv_usec, .

0

Source: https://habr.com/ru/post/1771679/


All Articles