仅主键和主键约束有什么区别? [英] What is the difference between Primary Key only and Primary Key constraint?

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

问题描述

我对SQL还是很陌生,如果我的问题很傻,请原谅我的无知。

I am very new to SQL and if my question is silly please forgive my ignorance.

仅主键和主键约束之间有什么区别?

What is the difference between Primary Key only and Primary Key constraint?


之间的差异

CREATE TABLE CUSTOMERS(
   ID   INT              NOT NULL,
   PRIMARY KEY (ID, NAME)

This

CREATE TABLE CUSTOMERS(
   ID   INT              NOT NULL,
  CONSTRAINT [Pk_ID_Name] PRIMARY KEY (ID, NAME)

谢谢,
Dash

Thank you, Dash

推荐答案

在第二个版本中,您可以为约束添加一个名称,允许您使用该名称来删除它

In the second version, you can give a name to your constraint, allowing you to drop it using the name instead of having to name every column of a composite constraint.

否则,他们会做同样的事情。

Otherwise, they do the same thing.

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

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