Hitesh
Hitesh

Reputation: 152

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

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;

Upvotes: 0

Views: 2285

Answers (2)

Eric Leroux
Eric Leroux

Reputation: 11

I would do :

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

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

Upvotes: 1

Anonymous
Anonymous

Reputation: 557

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` ;

Upvotes: 1

Related Questions