在数据库表中创建pimary密钥 [英] creating pimary key in a database table

查看:115
本文介绍了在数据库表中创建pimary密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已将套餐ID作为主键





一个例子

ID-4111

name- customer

ledger-1

ename-SHAKEER





但是第二次

ID-4111

name-supplier

分类帐-2

ename-shakeer



我可以像这样创建

解决方案
否。 ID不能具有重复值,这意味着该表中不能有多个具有相同值4111的ID。在表中指定为主键的列只能包含唯一值。主键的目的是确保表中没有重复记录。通过本快速指南了解有关关系数据库的更多信息,请访问 Relational_Database_Design.html [ ^ ]


您正在寻找复合主键 [ ^ ]


您好,



主键是唯一键。你不能像那样创造



I have crated ID as primary key


For an example
ID-4111
name- customer
ledger-1
ename-SHAKEER


but for 2nd time
ID-4111
name-supplier
ledger-2
ename-shakeer

can i create like this

解决方案

No. The ID cannot have duplicate value, that means there cannot be more than one ID with the same value of 4111 in that table. The column that is designated as primary key in a table can only contain unique values. The purpose of primary key is to ensure that there is no duplicate records in a table. Learn more about relational database from this quick guide Relational_Database_Design.html[^]


You're looking for Composite Primary Keys[^]


Hi ,

Primary key is Unique one. u can't create like that


这篇关于在数据库表中创建pimary密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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