I tried creating a field as a TINYINT(1)
, NOT NULL
and a DEFAULT
value of -1 to indicate 'unknown', but I got this error from my client:
Error altering MyTable: 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 '' at line 1
I also tried making the length 2 and got the same message
Guessing TINYINT
isn't the right data type for this kind of designation, but what is?
EDIT: I got it working after reading Ed Cottrell's comment. I think there was an extra character somewhere, here was the statement that my client (using Querious for Mac) generated:
ALTER TABLE `DBName`.`MyTable`
CHANGE COLUMN `MyColumn` `MyColumn` TINYINT(1) NOT NULL DEFAULT -1 COMMENT ''
AFTER `MyOtherColumn`;
Noticed that COMMENT
there and made sure everything was clean.
Other comments and answers were appreciated; I have decided to let NULL
mean unknown in this case