SQL键,MUL,PRI和UNI [英] SQL keys, MUL vs PRI vs UNI

查看:308
本文介绍了SQL键,MUL,PRI和UNI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MySQL中MULPRIUNI有什么区别?

What is the difference between MUL, PRI and UNI in MySQL?

我正在使用以下命令处理MySQL查询:

I'm working on a MySQL query, using the command:

desc mytable; 

其中一个字段显示为MUL键,其他字段显示为UNIPRI.

One of the fields is shown as being a MUL key, others show up as UNI or PRI.

我知道,如果键为PRI,则每个表只能将一个记录与该键关联.如果键为MUL,是否表示可能有多个相关记录?

I know that if a key is PRI, only one record per table can be associated with that key. If a key is MUL, does that mean that there could be more than one associated record?

这是mytable的响应.

+-----------+---------+------+-----+---------+-------+
| Field     | Type    | Null | Key | Default | Extra |
+-----------+---------+------+-----+---------+-------+
| courseid  | int(11) | YES  | MUL | NULL    |       | 
| dept      | char(3) | YES  |     | NULL    |       | 
| coursenum | char(4) | YES  |     | NULL    |       | 
+-----------+---------+------+-----+---------+-------+

推荐答案

这意味着该字段是非唯一索引(的一部分).您可以发出

It means that the field is (part of) a non-unique index. You can issue

show create table <table>;

查看有关表结构的更多信息.

To see more information about the table structure.

这篇关于SQL键,MUL,PRI和UNI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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