当前位置:网站首页>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 表分区
边栏推荐
猜你喜欢
随机推荐
让小程序开发进入 `tailwind jit` 时代
中国融资租赁行业市场投资分析与前景战略规划建议报告2022~2028年
7.16(6)
下拉框数据字典应用案例
Apache2-XXE漏洞渗透
【扫雷】多方法超详细 7.28
当奈飞的NFT忘记了web2的业务安全
lintcode2330 · 计算x秒后的时间
Go (一) 基础部分2 -- if条件判断,for循环语句
【圣诞节给爱的人打印一颗圣诞树吧】超详细代码实现——圣诞树打印
Playing with Markdown(2) - Extraction and Manipulation of Abstract Syntax Trees
编程软件配备
【IDEA】字体修改-护眼主题-文件注释头设置
npm run dev/serve 时报错
Try setting CHROME_EXECUTABLE to a Chrome executable
Makefile介绍
pta a.1003 的收获
陆运信息系统——班列项目总结(一)
Flask,3-6
动态调整web主题(2) 萃取篇