Reputation: 1179
I am trying to add a column into mysql table using this query but mysql is complaining about syntax. I have seen number of sources but I am unable to see whats wrong here.
mysql> ALTER TABLE dog add date TIMESTAMP(14);
error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '(14)'
at line 1
table name 'dog', column name 'date'
Upvotes: 3
Views: 2574
Reputation: 932
quote ALTER TABLE dog add date
TIMESTAMP(14); date is reserved word use alt + 96
that is the correct
ALTER TABLE dog ADD `date` TIMESTAMP;
thats work checked
Upvotes: 1
Reputation: 17434
DATE is a special word in MySQL, so you'll need to put backticks around it:
mysql> ALTER TABLE dog add `date` TIMESTAMP;
Upvotes: 6