This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 问个概念性问题:在database中,primary key 和 index在功能和性能上有何区别.为何在DB2中,增加一个primary key会影响SYSCAT.INDEX表呢?让我confuse.
-ivy_sh(蝶);
2002-9-5
(#730363@0)
-
primary key is unique for its each values and one table can only have onehowever, one table can havre multiple index which is unique and no unique
-mark80(mark);
2002-9-5
{73}
(#730395@0)
-
Primary key is a unique constraint and can be used as a parent key in RI. A unique primary index is created by DB2 when you define a primary key. Index can be either unique or non-unique.
-wdding(wdding);
2002-9-5
(#730563@0)
-
那是否可以说: 在某种意义上讲,primary key是index的子集了
-ivy_sh(纸蝶);
2002-9-5
(#730946@0)
-
建index是为了加快查询速度,PRIMARY KEY主要用于标识唯一记录同时还具有INDEX功能。
-easyway(老树发新芽);
2002-9-5
(#730956@0)
-
不能这样看吧?index和primary key是两个不同的概念。
-henhen(哼哼~~,找工ing~~~~);
2002-9-5
(#731011@0)
-
What’s the difference between
(1) CREATE TABLE blah (bee1 char(10) PRIMARY KEY)
(2) CREATE TABLE blah (bee1 char(10) NOT NULL)
CREATE UNIQIE INDEX i1 on blah (bee1)
-ivy_sh(纸蝶);
2002-9-6
(#731783@0)
-
My understanding is that the implementation of primary key in RDBMS is to create a unique index on it. But primary key and index are for sure two different concepts.
-freshair(Happy pig);
2002-9-6
(#731975@0)
-
you got it.
-henhen(哼哼~~,找工ing~~~~);
2002-9-6
(#731989@0)
-
Yes. So if you has a primary key(column1,column2), you don't need create another unique index(column1,column2)
-ivy_sh(纸蝶);
2002-9-6
(#731998@0)
-
If you're not applying RI, there is no difference.
-wdding(wdding);
2002-9-6
(#732273@0)
-
看不明白,难道PK 和 Index有关系吗?
-hugefox(长得象熊的狐狸);
2002-9-6
(#732303@0)
-
Yes.刚查了资料,在DB2中因为DB2 won't allow indexes with the same difinition to be created. ,所以如果已创建primary key(column1), 则不可以再创建对column1的索引了.
-ivy_sh(纸蝶);
2002-9-6
(#732358@0)
-
在Sybase中,它们是有区别的设为pirmary key的cloumn不允许null值
而create unique index的column允许一个null
不知其他数据库怎么样?
-dibert(呆伯);
2002-9-8
{102}
(#735192@0)
-
DB2 has same thing
-ivy_sh(纸蝶);
2002-9-9
(#736475@0)
-
Index和Primary Key是两个完全不同的东西。在SQL Server数据库中,Primary Key是一个约束,和外键一同来保证数据库间的数据完整性。primary Key需要Index的支持,关系仅此而已。其它数据库也应该大同小异
-miketany(MIKE老狼);
2002-9-8
(#735708@0)
-
sorry,其实是我的问题问的不妥.问题该是"PRIMARY KEY和INDEX有何隐含的关系?"才符合我的疑惑.我搜索了一下各网站,赫赫,象我这样问的人还有一些.看来混淆了概念的人不止我一个:)
-ivy_sh(纸蝶);
2002-9-9
(#736473@0)