sql serevr中主键和外键之间的区别是什么 [英] what is the difference between primary key and foreign key in sql serevr

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

问题描述

嗨...

i面对面试时他在sql server中问我一个问题

主键和外键之间有什么区别sql serevr



然后没有回答它..

i不能想在我的下次采访中指出这个错误所以给我正确答案

解决方案

请参阅此处 [ ^ ],305,000个结果等着你回答。



..简而言之:

主键:

不允许空值重复值



外键:

它将允许空值Duplicte values并且引用到anoter表中的主键


http://rasadulalam.blogspot.com/2013/01/difference-between-primary-key-and.html [ ^ ]

1.每个表只允许一个主键,但每个表可能有多个外键。

2.Primary key不允许空值允许外键中的和重复值

3.如果主键值不可用,则无法将外键列值插入表中。但是可以反转。

4.如果将外键引用设置到表中,则无法删除主键值。但是可以反向。


hi...
i am facing the interview he asking me a one question in sql server
what is the difference between primary key and foreign key in sql serevr

then didnt answer it..
i can not be wants to comit this mistake in my next interview so give me the proper answer

解决方案

See here[^], 305,000 results waiting to answer you.

..and in short:
Primary Key:
It will not allow "Null values" and "Duplicate values"

Foreign Key:
It will allow "Null values" and "Duplicte values" and it refers to a primary key in anoter table.


http://rasadulalam.blogspot.com/2013/01/difference-between-primary-key-and.html[^]


1.There is only one primary key allowed per table but you may have more than one foreign key per table.
2.Primary key will not allowed "null values" and "Duplicate values" while in foreign key allowed
3.You can't insert foreign key column value into table if primary key value not available.but reverse is possible.
4.You can't delete primary key value if foreign key reference is set into table.but reverse is possible.


这篇关于sql serevr中主键和外键之间的区别是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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