简体   繁体   中英

mysql cannot execute user_id

Here there is an image of me making my MySQL table, but when im trying to save it, it gets up an error that

#1089 - Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys

[ 图片描述 1

Here you can see how the error looks like in the SQL Editor, the will be a code in bottom of the descriptiong (SQL query CODE)

图片描述

CREATE TABLE `User_System`.`usersystem` (
    `user_id` INT(11) NOT NULL AUTO_INCREMENT ,
    `username` VARCHAR(25) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
    `password` VARCHAR(1024) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
    `first_name` VARCHAR(40) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
    `last_name` VARCHAR(40) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
    `active` INT(10) NOT NULL DEFAULT '0' ,
    PRIMARY KEY (`user_id`(11)))
ENGINE = InnoDB CHARACTER SET latin1 COLLATE latin1_swedish_ci
COMMENT = 'User login and register';

remove the (11) from your primary key definitions. the key should contain column names only, not their type or size

From the error: "the used key part isn't a string". So don't use a prefix key. :)

The size specifier on integers is just a display hint; it's not actually part of the type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM