enterprize
enterprize

Reputation: 1179

What is wrong with this alter table query?

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

Answers (3)

Carlos Cocom
Carlos Cocom

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

Interrobang
Interrobang

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

Chibuzo
Chibuzo

Reputation: 6117

date is a keyword in mysql, I'll suggest you use something else

Upvotes: 0

Related Questions