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?
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`
MySQL
documentation dev.mysql.com/doc/refman/5.6/en/datetime.html for more information.
not null
column without default value would fail if the table already has data, but I would expect a different error message. Still, you could try giving it a default value. I think create time and update time can be automatically entered by MySQL. -edit- Yes, see auto-initializing timestamps (It is for timestamps, not datetime).