Dale_H Posted August 27, 2003 Share Posted August 27, 2003 I am teaching my self database and I ran into a snage, my table will not build right. here is my bad code CREATE TABLE `Monitors` ( `Type` TEXT( 25 ) NOT NULL , `Size` INT( 10 ) NOT NULL , `Price` FLOAT( 10 ) NOT NULL , `Descripton` LONGTEXT( 60 ) NOT NULL , PRIMARY KEY ( `Type` ) ) COMMENT = \'The type, size, price, and description of the moniters in stock.\' and here is the error MySQL said: You have an error in your SQL syntax near \'(25) NOT NULL, `Size` INT(10) NOT NULL, `Price` FLOAT(10) NOT NULL, `Descripton`\' at line 1 P.S. This is not a home work or anything, this is just a exsample database Any help would be cool Quote Link to comment https://forums.phpfreaks.com/topic/946-a-newbie-question/ Share on other sites More sharing options...
effigy Posted August 27, 2003 Share Posted August 27, 2003 you cannot specify the lengths for the TEXT and LONGTEXT fields; the exception is your TEXT field needs a length specified because it is the primary key: this length is placed in the primary key line. CREATE TABLE `Monitors` ( `Type` TEXT NOT NULL, `Size` INT(10) NOT NULL, `Price` FLOAT(10) NOT NULL, `Descripton` LONGTEXT NOT NULL, PRIMARY KEY (`Type`(25)) ) COMMENT = \'The type, size, price, and description of the moniters in stock.\' Quote Link to comment https://forums.phpfreaks.com/topic/946-a-newbie-question/#findComment-3204 Share on other sites More sharing options...
Dale_H Posted August 27, 2003 Author Share Posted August 27, 2003 thank you Quote Link to comment https://forums.phpfreaks.com/topic/946-a-newbie-question/#findComment-3207 Share on other sites More sharing options...
Dale_H Posted August 28, 2003 Author Share Posted August 28, 2003 I am using PHP My Admin, how do you add the number to the key if posable? Quote Link to comment https://forums.phpfreaks.com/topic/946-a-newbie-question/#findComment-3211 Share on other sites More sharing options...
Barand Posted August 30, 2003 Share Posted August 30, 2003 If `type` is a model number or something like that (which would make more sense as a primary key) then define it as varchar(25). TEXT fields will hold a short novel. CREATE TABLE `Monitors` ( `Type` VARCHAR(25) NOT NULL, `Size` INT(10) NOT NULL, `Price` FLOAT(10) NOT NULL, `Descripton` TEXT NOT NULL, PRIMARY KEY (`Type`) ) Quote Link to comment https://forums.phpfreaks.com/topic/946-a-newbie-question/#findComment-3243 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.