vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| hello I try to create a table with this statment CREATE TABLE referants ( id int(10) DEFAULT '0' NOT NULL auto_increment, referant char(200) NOT NULL, hits int(10) DEFAULT '0' NOT NULL, UNIQUE id (id) ); but MySQL return a error message #1067 - Invalid default value for 'id' and because I'm a beginner I don't know how to avoid this error thanks for your help bruno |
| |||
| Użytkownik "bruno - bdf" <bruno.bdf@free.fr> napisał w wiadomości news:443767de$0$20270$626a54ce@news.free.fr... > I try to create a table with this statment > CREATE TABLE referants ( > id int(10) DEFAULT '0' NOT NULL auto_increment, You cannot use 'DEFAULT something' and 'auto_increment' in the same statement. You should remove DEFAULT and leave auto_increment only - as you wish unique id. You can also remove 'NOT NULL'. -- JasiekS Warsaw, Poland |
| |||
| bruno - bdf wrote: > hello > I try to create a table with this statment > CREATE TABLE referants ( > id int(10) DEFAULT '0' NOT NULL auto_increment, > referant char(200) NOT NULL, > hits int(10) DEFAULT '0' NOT NULL, > UNIQUE id (id) > ); > > but MySQL return a error message > #1067 - Invalid default value for 'id' > > and because I'm a beginner I don't know how to avoid this error > > thanks for your help > > bruno > > > You don't use a default value for an auth_increment column. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
| ||||
| bruno - bdf wrote: > hello > I try to create a table with this statment > CREATE TABLE referants ( > id int(10) DEFAULT '0' NOT NULL auto_increment, > referant char(200) NOT NULL, > hits int(10) DEFAULT '0' NOT NULL, > UNIQUE id (id) > ); As other folks have stated, having a default for an auto_increment column is not appropriate. In addition, I'd recommend making the default for your hits column be simply 0, not '0' with the quotes. The former is an integer, the latter is a string. Regards, Bill K. |