SGG
SGG

Reputation: 165

Is there any difference between TIMESTAMP(3) & TIMESTAMP

Is there any difference between TIMESTAMP(3) & TIMESTAMP I am generating liquibase from mysql & while creating it throws an error

<column defaultValueComputed="CURRENT_TIMESTAMP" name="createdate" type="TIMESTAMP(3)">
Invalid default value for 'createdate' [Failed SQL: CREATE TABLE

But it works I use TIMESTAMP


Problem is that when data is persisted in DB with TIMESTAMP like 2018-03-15 06:49:06 but when I create a table with TIMESTAMP(3) data persist like 2018-01-03 07:54:56.867 Last millisecond value I need

Upvotes: 5

Views: 17741

Answers (1)

Aishwer Sharma
Aishwer Sharma

Reputation: 295

As per mysql doc: https://dev.mysql.com/doc/refman/5.6/en/datetime.html

By default, timestamp does not contain milliseconds field Ex: "2020-11-06 13:46:33"

But timestamp(3) stores milliseconds as well with precision as added in brackets (max 6). Ex: "2020-10-19 13:27:05.912"

Upvotes: 3

Related Questions