我应该索引Oracle中的主键列吗? [英] Should I index primary key column(s) in Oracle

查看:330
本文介绍了我应该索引Oracle中的主键列吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近停止认为主键不是索引,它们是Unique和Null约束的组合。到目前为止,我从未为PK列创建索引。我的问题是,如果要在许多查询的WHERE部分中使用此列,我是否应该为PK列创建索引。

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.

推荐答案

Oracle将为您创建索引,或者可以使用现有索引。是否使用唯一索引或非唯一索引取决于您。

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.

这篇关于我应该索引Oracle中的主键列吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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