Home > Net >  Alter table in mysql, add column error 1064 (42000)?
Alter table in mysql, add column error 1064 (42000)?

Time:07-12

I am trying to add column in mysql table but following error thrown.

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 'ALTER TABLE cm_article ADD COLUMN active INT NOT NULL DEFAULT '0' AFTER description'

My Sql Statement is: ALTER TABLE cm_article ADD COLUMN active INT NOT NULL DEFAULT '0' AFTER description;

CodePudding user response:

There are two different types of quotation marks in MySQL. You need to use ` for column names and ' for strings. Since you have used ' for the filename column the query parser got confused.

ALTER TABLE `cm_article` ADD COLUMN `active` INT NOT NULL DEFAULT '0' AFTER `description` ;

CodePudding user response:

I would do :

ALTER TABLE cm_article
ADD COLUMN active INT NOT NULL DEFAULT(0)
AFTER description;

If it doesn't work, modify 'ADD COLUM' with just 'ADD'

  • Related