当前位置:网站首页>Oracle 分区索引详解(local、global)
Oracle 分区索引详解(local、global)
2022-08-03 05:22:00 【鱼丸丶粗面】
1 概述
2 分区索引
2.1 本地分区索引
create table scott.partition (
p_id number,
p_id2 number,
p_name varchar2(50),
p_date date
) partition by range(p_id)(
partition p1 values less than (20000),
partition p2 values less than (40000),
partition p3 values less than (80000),
partition p4 values less than (100000),
partition p5 values less than (maxvalue)
);
-- 试图创建本地分区索引
-- ORA-14024: local 索引的分区数必须等于基础表的分数数,如: 3 != 5
create index scott.partition_local on scott.partition(p_id)
local(partition p1,
partition p2,
partition p3);
-- 创建本地分区索引
create index scott.partition_local on scott.partition(p_id)
local(partition p1, -- 索引分区个数 必须与 表分区数 完全对应
partition p2,
partition p3,
partition p4,
partition p5);
-- drop index scott.partition_local;
-- 等同上述,写法简洁,推荐
create index scott.partition_local on scott.partition(p_id)
local;
-- 默认:普通索引(非分区索引)
create index scott.partition_normal on scott.partition(p_name);
-- p_id 是 表分区列,故 scott.partition_local 为 本地前缀分区索引
-- p_id2 不是 ..., 故 scott.partition_local2 为 本地非...
create index scott.partition_local2 on scott.partition(p_id2)
local;
2.2 全局分区索引
create index scott.partition_global on scott.partition(p_date)
global partition by range(p_date)
(partition pg1 values less than(to_date('2020-01-01', 'YYYY-MM-DD')),
partition pg2 values less than(to_date('2021-01-01', 'YYYY-MM-DD')),
partition pg3 values less than(to_date('2022-01-01', 'YYYY-MM-DD')),
partition pg4 values less than(to_date('2023-01-01', 'YYYY-MM-DD')),
partition pg5 values less than(maxvalue));
-- drop index scott.partition_global;
-- 同理,若分区表已存在列分区,以下为简洁写法
create index scott.partition_global on scott.partition(p_date)
global;
2.3 索引查询
-- 分区索引
select * from dba_part_indexes;
select * from dba_ind_partitions;
-- 普通索引
select * from dba_indexes;
3 扩展
3.1 表分区
边栏推荐
猜你喜欢
随机推荐
中国生物降解塑料行业市场运营态势及发展趋势研究报告2022~2028年
【DC-2靶场渗透】
【命令执行与中间件漏洞】
动态调整web主题(2) 萃取篇
MySQL 索引检索原理和B+Tree数据结构详解
controller层到底能不能用@Transactional注解?
C语言简单实现三子棋小游戏
浏览器中的 preview 和 response 的值不一致
漫谈Map Reduce 参数优化
Django从入门到放弃三 -- cookie,session,cbv加装饰器,ajax,django中间件,redis缓存等
玩转Markdown(2) —— 抽象语法树的提取与操纵
【myPow,2次幂,3次幂..代码实现】
嵌入式实验四
MySQL 安装报错的解决方法
【Yarn】yarn常用命令 查看日志和Kill任务
ansible的安装和部署详细过程,配置清单基本操作
关于semantic-ui的cdn失效问题(怎样通过本地引用semantic-ui)
【Arduino】关于“&”和“|” 运算-----多个参数运算结果异常的问题解决
7.16(6)
中国柔性制造系统(FMS)市场发展动态及未来趋势预测报告2022~2028年









