Should I index primary key column(s) in Oracle

北战南征 提交于 2019-11-30 07:54:03

问题


I've recently stopped to think that Primary Keys are not indexes, they're a combination of Unique and Null constraints. And till now, I've never created index for PK columns. My question is if I should create index for PK columns if this column is going to be used in the WHERE part of many queries.


回答1:


Oracle will create an index for you, or can use an existing one. Whether a unique or non-unique index is used is up to you.

http://docs.oracle.com/cd/B28359_01/server.111/b28310/indexes003.htm#i1006566

A primary key itself is not an index, and nor is a unique constraint -- they are both constraints. However an index is used to support them.

A unique index is rather different as it can exist in the absence of a unique or primary key constraint, and neither constraint type require that the index supporting it be unique.



来源:https://stackoverflow.com/questions/15703640/should-i-index-primary-key-columns-in-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!