Matik
Matik

Reputation: 29

MySQL Incorrect syntax near 'MODIFY'

someone know what is bad?

ALTER TABLE "stats"
  MODIFY "id" int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;
Incorrect syntax near 'MODIFY'.

idk what is wrong, someone can help?

Upvotes: 0

Views: 1672

Answers (2)

subhadip pahari
subhadip pahari

Reputation: 846

short answer: instead of " (double quotes ) use ` (backticks)

Long answer :

Backticks are used in MySQL to select columns and tables from your MySQL source. In the example below, we are calling to the table titled Album and the column Title. Using backticks we are signifying that those are the column and table names.

ALTER TABLE `stats`
MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;

or, The backticks for column names may not be necessary though.

ALTER TABLE stats
MODIFY id int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;

Upvotes: 1

nbk
nbk

Reputation: 49385

Instead of using double quotes use backticks, also an Auto_increment must be PRIMARY KEY

ALTER TABLE `stats`
  MODIFY `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, AUTO_INCREMENT=2;
COMMIT;

Upvotes: 2

Related Questions