#1089在phpMyAdmin中创建表时出错

时间:2015-06-16 10:25:33

标签: mysql

在创建表格时,我收到错误#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';

3 个答案:

答案 0 :(得分:9)

您必须删除密钥的长度:

PRIMARY KEY (`BBZUID`) , 

而不是

PRIMARY KEY (`BBZUID`(9)) , 

答案 1 :(得分:1)

SQL代码

而不是主键(' id'(10));

它将是主键(' id');

答案 2 :(得分:0)

  1. 去预览SQL
  2. 复制SQL语法
  3. 更改SQL语法的这一部分:

    主键(BBZUID(9))->主键(BBZUID