在创建表时,出现错误#1089-不正确的前缀键。

我的SQL代码:

CREATE TABLE `buildblockz`.`db_user_info` ( `BBZUID` INT(11) UNSIGNED   NOT NULL AUTO_INCREMENT COMMENT 'User''s Id' , `username` VARCHAR(255) NOT NULL COMMENT 'User''s username' , `password` VARCHAR(255) NOT NULL COMMENT 'User''s password' , `fname` VARCHAR(255) NOT NULL COMMENT 'User''s First Name' , `mname` VARCHAR(255) NULL COMMENT 'User''s Middle Name' , `lname` VARCHAR(255) NOT NULL COMMENT 'User''s Last Name' , `line1` VARCHAR(255) NOT NULL COMMENT 'User''s Address Line 1' , `line2` VARCHAR(255) NULL COMMENT 'User''s Address Line 2' , `city` VARCHAR(255) NOT NULL COMMENT 'User''s Address City' , `state` VARCHAR(255) NOT NULL COMMENT 'User''s Address State' , `pincode` INT(11) UNSIGNED NOT NULL COMMENT 'User''s Address Pincode' , `email` VARCHAR(255) NOT NULL COMMENT 'User''s Contact Email' , `mobile` INT(11) UNSIGNED NULL COMMENT 'User''s Contact Mobile' , `phone` INT(11) UNSIGNED NULL COMMENT 'User''s Contact Phone' , `sex` ENUM('M','F','NS') NOT NULL COMMENT 'User''s Sex' , `dateOfBirth` DATE NOT NULL COMMENT 'User''s Date of Birth' , `designation` VARCHAR(255) NULL COMMENT 'User''s Designation' , `dateOfEntry` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'User''s Date of Entry' , PRIMARY KEY (`BBZUID`(9)) , UNIQUE (`username`(30)) ) ENGINE = InnoDB COMMENT = 'User''s Database';

最佳答案

您必须删除 key 的长度:

PRIMARY KEY (`BBZUID`) ,

代替
PRIMARY KEY (`BBZUID`(9)) ,

10-01 17:24