Details
-
New Feature
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Won't Do
-
1.2.3
-
None
Description
Nanoseconds in MariaDB
----------------------------------------
Currently we have Microseconds in MariaDB
https://mariadb.com/kb/en/library/microseconds-in-mariadb/
|
MariaDB [test]> SELECT CAST('2009-12-31 23:59:59.9876543210' as DATETIME(6));
|
+-------------------------------------------------------+
|
| CAST('2009-12-31 23:59:59.9876543210' as DATETIME(6)) |
|
+-------------------------------------------------------+
|
| 2009-12-31 23:59:59.987654 |
|
+-------------------------------------------------------+
|
1 row in set, 1 warning (0.000 sec)
|
|
MariaDB [test]> SELECT CAST('2009-12-31 23:59:59.9876543210' as DATETIME(10));
|
ERROR 1426 (42000): Too big precision 10 specified for '2009-12-31 23:59:59.9876543210'. Maximum is 6
|
|
MariaDB [test]> SELECT CAST('2009-12-31 23:59:59.9876543210' as DATETIME(9));
|
ERROR 1426 (42000): Too big precision 9 specified for '2009-12-31 23:59:59.9876543210'. Maximum is 6
|
|
Nanoseconds in MariaDB
It ranges from 0 to 9, meaning that we can use the TIMESTAMP data type to store up to nanosecond. Currently MariaDB support fractional seconds precision sets to microsecond.
|
MariaDB [test]> SELECT TIME'10:10:10.1234567890';
|
+---------------------------+
|
| TIME'10:10:10.1234567890' |
|
+---------------------------+
|
| 10:10:10.123456 |
|
+---------------------------+
|
1 row in set, 1 warning (0.001 sec)
|
|
For example :-
I have two timestamps i.e. start= 15-03-11 15:10:10 and finish=15-03-11 15:10:10 and i need to subtract them ("finish-start" ) in order to find the duration.
Because their difference is in nanosecond level, I need to have them into 15:10:10.000000001 and 15:10:10.000000015 respectively.
TIMESTAMP [(<nanosecond precision)]
|
|
Attachments
Issue Links
- relates to
-
MDEV-18843 Nanoseconds in MariaDB
- Open