oracle自动索引,在哪些情况下,Oracle会自动创建索引?

首先,当我们创建主键或唯一键时,Oracle并不总是创建索引。如果该列上已经有索引,它将使用它来代替…

SQL> create table t23 (id number not null)

2 /

Table created.

SQL> create index my_manual_idx on t23 ( id )

2 /

Index created.

SQL> select index_name from user_indexes

2 where table_name = 'T23'

3 /

INDEX_NAME

------------------------------

MY_MANUAL_IDX

SQL>

…注意

MY_MANUAL_IDX

不是唯一的索引;这不重要…

SQL> alter table t23

2 add constraint t23_pk primary key (id) using index

3 /

Table altered.

SQL> select index_name from user_indexes

2 where table_name = 'T23'

3 /

INDEX_NAME

------------------------------

MY_MANUAL_IDX

SQL> drop index my_manual_idx

2 /

drop index my_manual_idx

*

ERROR at line 1:

ORA-02429: cannot drop index used for enforcement of unique/primary key

SQL>

还有一种情况是Oracle将自动创建索引:lob存储….

SQL> alter table t23

2 add txt clob

3 lob (txt) store as basicfile t23_txt (tablespace users)

4 /

Table altered.

SQL> select index_name from user_indexes

2 where table_name = 'T23'

3 /

INDEX_NAME

------------------------------

MY_MANUAL_IDX

SYS_IL0000556081C00002$$

SQL>

编辑

数据库将xmltype与其他lob处理相同…

SQL> alter table t23

2 add xmldoc xmltype

3 /

Table altered.

SQL> select index_name from user_indexes

2 where table_name = 'T23'

3 /

INDEX_NAME

------------------------------

MY_MANUAL_IDX

SYS_IL0000556081C00002$$

SYS_IL0000556081C00004$$

SQL>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值