Unknown CREATE TABLE syntax error

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Unknown CREATE TABLE syntax error



I've been staring at this simple CREATE TABLE query for 20 minutes, and I can't figure out why it's throwing an error:


CREATE TABLE


create table `schema_change` (
`schema_change_id` unsigned int not null auto_increment,
`major_release_number` unsigned int not null,
`minor_release_number` unsigned int not null,
`point_release_number` unsigned int not null,
`script_name` varchar(100) not null,
`date_applied` datetime not null,
constraint `pk_schema_change` primary key (
`schema_change_id`
)
);



The error returned is a basic syntax error, but I can't spot any syntax that's incorrect:



#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 'unsigned int not null, minor_release_number unsigned int not
null, point_rel' at line 3



What am I missing?



(Using MySQL version 5.1.73)




2 Answers
2



UNSIGNED is a type attribute, and must come after the type name: INT UNSIGNED, not UNSIGNED INT.


UNSIGNED


INT UNSIGNED


UNSIGNED INT





Aha. Knew it would be something extremely simple. Cheers!
– Kai
12 mins ago



You muse use unsigned after the type, as it modifies the type of int


int


create table `schema_change` (
`schema_change_id` int unsigned auto_increment,
`major_release_number` int unsigned not null,
`minor_release_number` int unsigned not null,
`point_release_number` int unsigned not null,
`script_name` varchar(100) not null,
`date_applied` datetime not null,
constraint `pk_schema_change` primary key (
`schema_change_id`
)
);



See in action here: http://sqlfiddle.com/#!9/685bf/1






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Better method to check all objects' parameters with a single call

Visual Studio Code: How to configure includePath for better IntelliSense results