sebastian_sabo Posted May 7, 2008 Share Posted May 7, 2008 I have an issue during the instalation of a database The message i get sounds like this: Error SQL query: CREATE TABLE categories( id int( 11 ) DEFAULT '0' NOT NULL AUTO_INCREMENT , parent_id int( 11 ) DEFAULT '1' NOT NULL , name varchar( 25 ) DEFAULT '' NOT NULL , description varchar( 255 ) DEFAULT '' NOT NULL , PRIMARY KEY ( id ) , KEY parent_id( parent_id ) , KEY name( name ) ); MySQL said: #1067 - Invalid default value for 'id' please help me to resolve this. Quote Link to comment Share on other sites More sharing options...
fenway Posted May 8, 2008 Share Posted May 8, 2008 I think you have to put default after NULL/NOT NULL... Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 8, 2008 Share Posted May 8, 2008 If you have fields which are set up as NOT NULL (meaning a value must be present in the field), they cannot have a default value, thus the error you are having. Only use DEFAULT when fields can have NULL values. Quote Link to comment Share on other sites More sharing options...
fenway Posted May 9, 2008 Share Posted May 9, 2008 If you have fields which are set up as NOT NULL (meaning a value must be present in the field), they cannot have a default value, thus the error you are having. I don't think so... I can' default an INT to 6 without the field being NULL-able. Quote Link to comment Share on other sites More sharing options...
mezise Posted May 12, 2008 Share Posted May 12, 2008 AUTO_INCREMENT field cannot have default value defined, because it is handled by MySQL engine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.