Reputation: 851
The following SQL statement has a syntax error according to phpMyAdmin, but I can't spot what it is. Any ideas?
CREATE TABLE allocations(
`student_uid` INT unsigned NOT NULL DEFAULT 0,
`active` INT unsigned NOT NULL DEFAULT 1,
`name` VARCHAR( 255 ) NOT NULL DEFAULT '',
`internal_id` VARCHAR( 255 ) DEFAULT '',
`tutor_uid` INT NOT NULL DEFAULT 0,
`allocater_uid` INT unsigned NOT NULL DEFAULT 0,
`time_created` INT NOT NULL DEFAULT 0,
`remote_time` FLOAT NOT NULL DEFAULT 0,
`next_lesson` VARCHAR NOT NULL DEFAULT -1,
PRIMARY KEY ( student_uid )
);
Upvotes: 0
Views: 300
Reputation: 1432
next_lesson` VARCHAR NOT NULL DEFAULT -1,
should be changed to
`next_lesson` VARCHAR(255) NOT NULL DEFAULT -1,
Upvotes: 0
Reputation: 54790
2 things I can think of:
I don't think you can set a varchar not null with an empty default, mysql might consider an empty string the same as null.
Set varchar fields to a string not a number, so:
next_lesson
VARCHAR NOT NULL DEFAULT '-1',
Upvotes: 0
Reputation: 8915
The VARCHAR type requires a size (and it's smart to use quotes around the value), so try replacing
`next_lesson` VARCHAR NOT NULL DEFAULT -1,
with
`next_lesson` VARCHAR(255) NOT NULL DEFAULT '-1',
Upvotes: 6