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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax error help with create table

Status
Not open for further replies.

lanewho

Technical User
Mar 4, 2003
2
CA
I am trying to create a user's table but got the following error. What is it that is wrong? Also I'm new to mysql, what is the difference between binary and unsigned? Thanks for the help

CREATE TABLE `tblUsers` (`UserID` MEDIUMINT(7) BINARY NOT NULL AUTO_INCREMENT, `FirstName` TINYTEXT(25) UNSIGNED NOT NULL, `LastName` TINYTEXT(30) UNSIGNED NOT NULL, `Email` TINYTEXT(40) UNSIGNED NOT NULL, `Street` TINYTEXT(40) UNSIGNED NOT NULL, `City` TINYTEXT(25) UNSIGNED DEFAULT \'Saskatoon\' NOT NULL, `PostalCode` TINYTEXT(6) UNSIGNED NOT NULL, `Province` TINYTEXT(3) UNSIGNED DEFAULT \'SK\' NOT NULL, `Phone` TINYTEXT(10) UNSIGNED NOT NULL, `Password` TINYTEXT(10) UNSIGNED NOT NULL, `ReferredBy` MEDIUMINT(7) BINARY NOT NULL , PRIMARY KEY (`UserID`), INDEX (`UserID`, `Email`, `Password`, `ReferredBy`))

MySQL said:

You have an error in your SQL syntax near 'BINARY NOT NULL AUTO_INCREMENT, `FirstName` TINYTEXT(25) UNSIGNED NOT NULL, `Las' at line 1

Back
 
New error

CREATE TABLE `tblUsers` (`UserID` MEDIUMINT(7) UNSIGNED NOT NULL AUTO_INCREMENT, `FirstName` TINYTEXT(25) UNSIGNED NOT NULL, `LastName` TINYTEXT(30) UNSIGNED NOT NULL, `Email` TINYTEXT(40) UNSIGNED NOT NULL, `Street` TINYTEXT(40) UNSIGNED NOT NULL, `City` TINYTEXT(25) UNSIGNED DEFAULT 'Saskatoon' NOT NULL, `PostalCode` TINYTEXT(6) UNSIGNED NOT NULL, `Province` TINYTEXT(3) UNSIGNED DEFAULT 'SK' NOT NULL, `Phone` TINYTEXT(10) UNSIGNED NOT NULL, `Password` TINYTEXT(10) UNSIGNED NOT NULL, `ReferredBy` MEDIUMINT(7) UNSIGNED NOT NULL , PRIMARY KEY (`UserID`), INDEX (`UserID`, `Email`, `Password`, `ReferredBy`), UNIQUE (`UserID`))

MySQL said:

You have an error in your SQL syntax near '(25) UNSIGNED NOT NULL, `LastName` TINYTEXT(30) UNSIGNED NOT NULL, `Email` TINYT' at line 1

 
It is not possible to specify a size for tinytext. Use varchar instead.

There is no point of having both UNIQUE and PRIMARY key for the same column.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top