Search code examples
mysqlsqlsyntaxalter

What is wrong with SQL syntax 'ALTER TABLE tablename'?


I'm trying to alter a table to add a new column.

ALTER TABLE RKxADR
ADD RK1 varchar(255);

I'm getting 'Error Code: 1064. 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 'ALTER TABLE RKxADR' at line 1'.

I've checked several times and the table name is correct. As far as I can tell ALTER TABLE is also the correct syntax.

Any pointers on what may be causing this error?

UPDATE

I tried the below code, got the same error...

ALTER TABLE RKxADR
ADD COLUMN RK1 varchar(255);

UPDATE II

I tried the below code, got the same error...

ALTER TABLE RKxADR;
ADD COLUMN RK1 varchar(255);

Solution

  • ALTER TABLE RKxADR ADD COLUMN RK1 varchar(255) not null DEFAULT(0);