简体   繁体   中英

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);
ALTER TABLE RKxADR ADD COLUMN RK1 varchar(255) not null DEFAULT(0);

Seems you have tried everything.If its not in production,then you can try command

systemctl restart mysql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM