oracle 分区条件加函数,oracle分区+分区索引+函数索引

本文探讨了数据库分区和索引的创建与使用,包括全局分区索引、局部分区索引、日期函数索引和字符串索引。通过示例展示了如何插入数据以及查询时如何利用索引来提高效率。此外,还提到了并行无日志建索引和开启日志的操作。
摘要由CSDN通过智能技术生成
create table test_zhi4

(

id number,

name varchar2(4000),

time date,

timestr varchar2(2)

)

partition by range(timestr)

(

partition t_range_1 values less than (01),

partition t_range_2 values less than (02),

partition t_range_3 values less than (03),

partition t_range_4 values less than (maxvalue)

);

--global分区索引

create index idx_parti_range_timestr on test_zhi4(timestr)

global partition by range(timestr)

(

partition t_range_1 values less than (01),

partition t_range_2 values less than (02),

partition t_range_3 values less than (03),

partition t_range_4 values less than (maxvalue)

);

--local分区索引

create index idx_parti_range_timestr on test_zhi4(timestr) local;

--日期函数索引

create index idx_test_zhi4_fun_time on test_zhi4(to_char(time ,'yyyy-mm-dd')); --字符串索引

create index idx_test_zhi4_func_time on test_zhi4(trunc(time)); --trunc索引

--插入数据

insert into test_zhi4 (id, name, time, timestr) values (1, 'q1', to_date('01-04-2015', 'dd-mm-yyyy'), '01');

--查询 观察是否走了索引

select * from test_zhi4 partition (t_range_1) where timestr = '01'; --走了索引分区

select * from test_zhi4 partition (t_range_1) where trunc(time) = date'2015-04-01'; --走了trunc索引

select * from test_zhi4 partition (t_range_1) where to_char(time ,'yyyy-mm-dd') = '2015-04-01'; --走了字符串索引

--并行无日志建索引

create index aml2010.idx_amlm_ars_coult_inf_his on aml2010.amlm_ars_coult_inf_his(cust_seq) parallel 4 nologging;

--打开日志

alter index aml2010.idx_amlm_ars_coult_inf_his noparallel logging;

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值