PDA

View Full Version : SQL syntax error


C-32
11-01-2009, 03:12 PM
Hi,

I want to create a new table in phpMyAdmin:


CREATE TABLE prijsvraag_titel2009
(
ID int NOT NULL,
prijsvraag_titel varchar(100) NOT NULL,
datum_aanmaak datetime NOT NULL DEFAULT CURDATE(),
PRIMARY KEY (ID)
)


this is not working.. i got an 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 ''prijsvraag_titel2009'
(
ID int NOT NULL,
prijsvraag_titel varchar(100) NOT N' at line 1

What is wrong with my syntax?

sneakyimp
11-21-2009, 05:52 PM
I'm not sure, but I don't think mysql will let you assign NOW() or CURTIME() as a default for a datetime field. You also need to specify how long your ID int is. This is closer, but doesn't get you the default current time.

CREATE TABLE `test`.`prijsvraag_titel2009` (
`ID` INT( 6 ) NOT NULL ,
`prijsvraag_titel` VARCHAR( 100 ) NOT NULL ,
`datum_aanmaak` DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
PRIMARY KEY ( `ID` )
)