Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#1089 Error when creating table in phpMyAdmin

Tags:

mysql

While creating a table I'm getting error #1089- Incorrect Prefix Key.

My sql code :

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';
like image 804
hodophile Avatar asked Jun 16 '15 10:06

hodophile


3 Answers

You have to remove the length of the key:

PRIMARY KEY (`BBZUID`) , 

instead of

PRIMARY KEY (`BBZUID`(9)) , 
like image 64
Jens Avatar answered Nov 20 '22 21:11

Jens


SQL code

instead of primary key('id'(10));

it would be primary key('id');

like image 35
Koyel Sharma Avatar answered Nov 20 '22 21:11

Koyel Sharma


  1. go to preview SQL
  2. copy SQL syntax
  3. change this part of SQL syntax:

    PRIMARY KEY (BBZUID(9)) -> PRIMARY KEY (BBZUID)

like image 33
mamal Avatar answered Nov 20 '22 20:11

mamal