主键和唯一约束有什么区别? [英] What is the difference between a primary key and a unique constraint?

查看:70
本文介绍了主键和唯一约束有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人在面试中问过我这个问题...

Someone asked me this question on an interview...

推荐答案

主键表上的一个唯一字段,但它的特殊性在于表将该行视为其键.这意味着其他表可以使用此字段来创建与其自身的外键关系.

A primary key is a unique field on a table but it is special in the sense that the table considers that row as its key. This means that other tables can use this field to create foreign key relationships to themselves.

唯一约束仅意味着特定字段必须是唯一的.

A unique constraint simply means that a particular field must be unique.

这篇关于主键和唯一约束有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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