当前位置:网站首页>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 表分区
边栏推荐
猜你喜欢
随机推荐
【按位取反,逻辑操作符,条件操作符,逗号表达式,下标引用,函数调用,结构体】操作符后续+表达式求值(上)
图的最短路径的核心——松弛技术
Playing with Markdown(2) - Extraction and Manipulation of Abstract Syntax Trees
Qlik Sense 字符串截取和拼接详解(Left、Right、&)
中国人造金刚石行业投资战略规划及发展前景预测报告2022~2028年
理论上的嵌入式跑马灯
动态调整web系统主题? 看这一篇就够了
【扫雷】多方法超详细 7.28
私有变量(private) 【详细+易懂】
7.7(5)
Leetcode刷题——一些用层次遍历解决的问题(111. 二叉树的最小深度、104. 二叉树的最大深度、226. 翻转二叉树、剑指 Offer 27. 二叉树的镜像)
关于如何向FastAPI的依赖函数添加参数
中国水产养殖行业市场投资分析及未来风险预测报告2022~2028年
中国认证认可服务行业“十四五”发展规划及经营模式分析报告2022~2028年
request.getParameter的结果为on
MySQL 唯一索引 UNIQUE KEY 会导致死锁?
Let small program development into ` tailwind jit ` era
用户登录验证程序的实现
陆运信息系统——班列项目总结(一)
NFT租赁提案EIP-5006步入最后审核!让海外大型游戏的链改成为可能









