English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

SQL query:

CREATE TABLE tickets(
ticket int( 10 ) unsigned DEFAULT '0' NOT NULL AUTO_INCREMENT ,
author varchar( 100 ) DEFAULT '' NOT NULL ,
recipient varchar( 100 ) DEFAULT '' NOT NULL ,
subject varchar( 100 ) DEFAULT '' NOT NULL ,
attachment tinyint( 1 ) unsigned DEFAULT '0' NOT NULL ,
timestamp int( 10 ) unsigned DEFAULT '0' NOT NULL ,
TYPE varchar( 15 ) DEFAULT '' NOT NULL ,
assignment int( 10 ) unsigned DEFAULT '0' NOT NULL ,
parent int( 10 ) unsigned DEFAULT '0' NOT NULL ,
activity int( 10 ) unsigned DEFAULT '0' NOT NULL ,
priority tinyint( 1 ) unsigned DEFAULT '1' NOT NULL ,
cc varchar( 100 ) DEFAULT '' NOT NULL ,
body text NOT NULL ,
PRIMARY KEY ( ticket ) ,
KEY parent( parent ) ,
KEY TYPE ( TYPE )
);

MySQL said: Documentation
#1067 - Invalid default value for 'ticket'

2006-12-13 08:25:38 · 2 answers · asked by Rj 3 in Computers & Internet Programming & Design

2 answers

For an AUTO_INCREMENT, you should not put a default value.

Try this instead:

ticket int(10) NOTNULL AUTO_INCREMENT PRIMARY KEY,

2006-12-13 08:31:06 · answer #1 · answered by Tim 6 · 1 0

As you are using auto_increment to generate a unique number it cannot have a default of 0 as the default will be set by the auto_increment

2006-12-13 08:29:02 · answer #2 · answered by Elizabeth Howard 6 · 1 1

fedest.com, questions and answers