我们可以在mysql表中使用多个主键吗? [英] can we use more than one primary keys in a mysql table

查看:1058
本文介绍了我们可以在mysql表中使用多个主键吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



i创建了一个表,一列作为主键,现在我想通过在mysql中添加auto_increment类型的serialno / index列来改变列通过使用代码

alter table tablename add columnname int auto_increment first,primarykey(columnname);

所以在表中有多个主键有任何问题



请重播我



问候

Ginnas

hello

i have create one table with one column as primary key, now i wanted to alter the column by adding the serialno/index column by auto_increment type in mysql by using the code
alter table tablename add columnname int auto_increment first,primarykey(columnname);
so is there any problem in having more than one primary key in a table

Please replay me

Regards
Ginnas

推荐答案

您不能拥有多个主键,而是可以将两列保持为主键
you cannot have more than one primary key instead you can keep both columns together as primary key


不!线索的名称是PrimaryKey。

就像你不能拥有两个主要联系人一样,你不能拥有两个主键。
No! The clue is in the name "PrimaryKey".
Just as you can''t have two "primary contact people", you can''t have two "primary keys".


这篇关于我们可以在mysql表中使用多个主键吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆