Salih Erikci Salih Erikci - 7 months ago 14
MySQL Question

Can't set a default value to INT(11) altering table

I am trying to alter a table and set a default value for a nullable column. But i get the following error.

Here is the command:

ALTER TABLE `questiontboard`.`questions`
CHANGE COLUMN `status` `status` (11) NULL DEFAULT 1 ;

Here is the error:

ERROR 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 '(11) NULL DEFAULT 1' at line 2
SQL Statement:
ALTER TABLE `questionboard`.`questions`
CHANGE COLUMN `status` `status` (11) NULL DEFAULT 1

ERROR: Error when running failback script. Details follow.

ERROR 1050: Table 'question' already exists

What am i doing wrong?


You forgot the data type. Did you mean

ALTER TABLE `questiontboard`.`questions` 
CHANGE COLUMN `status` `status` INT(11) NULL DEFAULT 1 ;