当前位置:网站首页>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 表分区
边栏推荐
猜你喜欢
Leetcode刷题——一些用层次遍历解决的问题(111. 二叉树的最小深度、104. 二叉树的最大深度、226. 翻转二叉树、剑指 Offer 27. 二叉树的镜像)
【解读合约审计】Harmony的跨链桥是如何被盗一亿美金的?
mysql 客户端SSL错误2026 (HY000)
MySQL 安装报错的解决方法
当奈飞的NFT忘记了web2的业务安全
Oracle 注释详解(--、/**/、rem)
7.24[C语言零基础 知识点总结]
嵌入式实验二
用C语言来实现五子棋小游戏
Browser multi-threaded off-screen rendering, compression and packaging scheme
随机推荐
Flask,7
A-B数对问题|UPC-Count Interval|洛谷-P1102A-B数对
The result of request.getParameter is on
嵌入式实验三(代码几乎都要改才能运行)
中国融资租赁行业市场投资分析与前景战略规划建议报告2022~2028年
7.16(6)
MySQL 排序
当我们在看Etherscan的时候,到底在看什么?
用C语言来实现五子棋小游戏
Apache2-XXE漏洞渗透
The ` monorepo ` ` hoist ` mechanism lead to the change of the loading configuration file path
【源码解读】你买的NFT到底是什么?
动态调整web系统主题? 看这一篇就够了
浏览器中的 preview 和 response 的值不一致
`monorepo` 中 `hoist` 机制导致加载配置文件路径的变化
Execute the mysql script file in the docker mysql container and solve the garbled characters
Go (一) 基础部分3 -- 数组,切片(append,copy),map,指针
【Nmap与Metasploit常用命令】
中国磷化铟晶圆行业发展前景与投资规划分析报告2022~2028年
中国生产力促进中心”十四五”规划与发展规模分析报告2022~2028年