Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is wrong with this??

Status
Not open for further replies.

manking

MIS
Jan 29, 2003
28
US
Using mysql 5 what is wrong with this statement?
Code:
DROP TABLE IF EXISTS messages_ulti;
CREATE TABLE messages_ulti(
     PRIMARY KEY (ID),
     ID INT(11) AUTO_INCREMENT,
     fromID VARCHAR(50) DEFAULT '',
     toID VARCHAR(50) DEFAULT '',
     Subject VARCHAR(50) DEFAULT "Welcomemessage from Webmaster!",
     Message LONGBLOB ,
     read SMALLINT DEFAULT '',
     INDEX fromID (fromID ASC),
     INDEX ID (ID ASC),
     INDEX toID (toID ASC)     ) ;
 
PRIMARY KEY (ID),
ID INT(11) AUTO_INCREMENT,

It might be just me, but I've don't create table like above, rather like so.

ID INT(11) PRIMARY KEY AUTO_INCREMENT,
 
The word READ is a reserved word so you should change the column name to something else.
 
A. "read" is a MySQL keyword. Either change it or enclose it in backticks.
B. '' is an invalid default value for a SMALLINT. Use 0.

This works:

DROP TABLE IF EXISTS messages_ulti;
CREATE TABLE messages_ulti(
PRIMARY KEY (ID),
ID INT(11) AUTO_INCREMENT,
fromID VARCHAR(50) DEFAULT '',
toID VARCHAR(50) DEFAULT '',
Subject VARCHAR(50) DEFAULT "Welcomemessage from Webmaster!",
Message LONGBLOB ,
`read` SMALLINT DEFAULT 0,
INDEX fromID (fromID ASC),
INDEX ID (ID ASC),
INDEX toID (toID ASC) ) ;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top