ITPub博客

首页 > 数据库 > Oracle > [20201110]oracle建立索引nosrt.txt

[20201110]oracle建立索引nosrt.txt

原创 Oracle 作者:lfree 时间:2020-11-10 09:45:00 0 删除 编辑

[20201110]oracle建立索引nosrt.txt

--//被别人问的问题,实际上这个参数很无聊,仅仅在表排序的情况下减少排序操作,要求你表中数据已经有序的情况下。

1.环境:
SCOTT@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.测试:
SCOTT@book> create table t1 as select * from dba_objects;
Table created.

SCOTT@book> create index i_t1_object_id on t1(object_id) nosort ;
create index i_t1_object_id on t1(object_id) nosort
                               *
ERROR at line 1:
ORA-01409: NOSORT option may not be used; rows are not in ascending order

--//表T1并没有按照object_id排序,建立索引时报错。

SCOTT@book> create table t2 as select * from dba_objects order by object_id;
Table created.

SCOTT@book> create index i_t2_object_id on t2(object_id) nosort ;
Index created.

--//表T2按照object_id排序,建立索引时OK。
--//除非你导入数据时按照该字段排序,建立的索引才有用。




来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2733170/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969333