asc和desc全称_关于使用索引排序 desc 和 asc

例子如下

首先建立环境

SQL> create table t nologging as select * from dba_objects;

表已创建。

SQL> insert /*+ append */into t select *from t;

已创建33599行。

SQL> commit;

提交完成。

SQL> insert /*+ append */into t select *from t;

已创建67198行。

SQL> commit;

提交完成。

SQL> insert /*+ append */into t select *from t;

已创建134396行。

SQL> commit;

提交完成。

SQL> update t set object_id=rownum;

已更新268792行。

SQL> alter table t add primary key(object_Id) nologging;

表已更改

SQL> create unique index tdix on t(object_type,created desc,object_id desc) nolo

gging;

索引已创建。

SQL> analyze table t compute statistics;

表已分析。

开始查询

按照索引排序的顺序

SQL> select /*+ first_rows  */table_a.*,rownum from (select

2  /*+ first_rows */* FROM   t

3    WHERE object_type='TABLE'

4       order by created desc,object_id desc )  table_a where rownum<=20

5  ;

已选择20行。

Execution Plan

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

0      SELECT STATEMENT Optimizer=HINT: FIRST_ROWS (Cost=3791 Card=

20 Bytes=3540)

1    0   COUNT (STOPKEY)

2    1     VIEW (Cost=3791 Card=7906 Bytes=1399362)

3    2       TABLE ACCESS (BY INDEX ROWID) OF 'T' (Cost=3791 Card=7

906 Bytes=679916)

4    3         INDE

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值