Cannot add DATETIME columns to MySQL table
25,252
Remove that size specifier (6)
from your ALTER
statement.
ALTER TABLE `Chessmates`.`User_Accounts`
CHANGE COLUMN `Country` `Country` TEXT(25) NOT NULL ,
ADD COLUMN `created_at` DATETIME NOT NULL AFTER `salt`,
ADD COLUMN `updated_at` DATETIME NULL DEFAULT NULL AFTER `created_at`
Author by
credo56
Updated on July 10, 2020Comments
-
credo56 almost 4 years
I'm trying to add two DATETIME columns to my User_Accounts table.
I create the columns in MySQL workbench like so: DATETIME(6)
What am I doing wrong?
-
credo56 almost 9 yearsThis worked, but why? MySQL workbench provides DATETIME() as a datatype, not DATETIME.
-
Rahul almost 9 yearsCheck
MySQL
documentation dev.mysql.com/doc/refman/5.6/en/datetime.html for more information. -
Rahim Khoja almost 8 yearsDATETIME(6) seems to of worked for me. It is only available in MySQL 5.7 and later . The number inside the brackets represents the amount of decimal places the fractional seconds can use ( microseconds ). DATETIME eg 2016-06-05 02:07:48 DATETIME(6) eg 2016-06-05 02:07:48.123456