mysql错误1068_MySql表,错误#1064&错误#1068定义了多个主键

bd96500e110b49cbb3cd949968f18be7.png

I have got errors when I tried to install the MySql tables, error:

"#1064 - You have an error in your SQL syntax"

and error:

"#1068 - Multiple primary key defined "

This is the database:

CREATE TABLE messages (

msg_id INT PRIMARY KEY AUTO_INCREMENT,

message VARCHAR(200),

uid_fk INT(10),

ip VARCHAR(45),

created INT(10),

uploads VARCHAR(50),

profile_uid INT(10)

PRIMARY KEY (`msg_id`),

KEY `uid_fk` (`uid_fk`)

);

CREATE TABLE comments (

com_id INT PRIMARY KEY AUTO_INCREMENT,

comment VARCHAR(200),

msg_id_fk INT(10),

uid_fk INT(10),

ip VARCHAR(45),

created INT(10),

PRIMARY KEY (`com_id`),

KEY `msg_id_fk` (`msg_id_fk`),

KEY `uid_fk` (`uid_fk`)

);

CREATE TABLE likes (

like_id INT PRIMARY KEY AUTO_INCREMENT,

msg_id_fk INT(10),

uid_fk INT(10),

PRIMARY KEY (`like_id`),

KEY `msg_id_fk` (`msg_id_fk`),

KEY `uid_fk` (`uid_fk`)

);

CREATE TABLE user_uploads (

id INT PRIMARY KEY AUTO_INCREMENT,

image_path VARCHAR(500),

uid_fk INT(10),

PRIMARY KEY (`id`),

KEY `uid_fk` (`uid_fk`)

);

CREATE TABLE follow_user (

fid INT PRIMARY KEY AUTO_INCREMENT,

uid_fk INT(10),

following_uid INT(10),

PRIMARY KEY (`fid`),

KEY `uid_fk` (`uid_fk`)

);

these are the errors images:

3Gb9V.png

G1FOu.png

How to fix it?

解决方案

Either use the inline syntax (msg_id INT PRIMARY KEY AUTO_INCREMENT) or declare it afterwards (PRIMARY KEY (com_id)), not both : they conflict.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值