匿名用户Oracle 11g 表按月自动分区, 索引也可以按月分区吗?
首分将表按时间进行分区,然后创建本地索引可实现索引按月分区:

评论
有用 3索引分区分为本地索引分区和全局索引分区
本地索引分区
使用和分区表同样的分区键进行分区的索引,也就是说,索引分区所采用的列表与该表的分区所采用的列是相同的。
--创建学生表,共有三个分区
create table studentgrade
(
id number primary key,
name varchar2(10),
subject varchar2(10),
grade number
)
partition by range(grade)
partition par_nopass values less than(60) tablespace ts_1,
partition par_pass values less than(70) tablespace ts_2,
partition par_good values less than (maxvalue) tablespace ts_3
);
--根据表分区创建本地索引分区
create index grade_index on studentgrade(grade )
local
(
partition p1 tablespace ts_1,
partition p2 tablespace ts_2,
partition p3 tablespace ts_3
)
本地索引分区的优点:
1.如果只有一个分区需要维护,则只有一个本地索引受影响。
2.支持分区独立性
3.只有本地索引能够支持单一分区的装入和卸载。
4.分表区和各自的本地索引可以同时恢复。
5.本地索引可以单独重建。
6.位图索引仅由本地索引支持。
全局索引分区
全局索引就是没有与分区表采用相同分区键的分区索引。当分区中出现许多事务并且要保证所有分区中的数据记录唯一时,采用全局索引分区。
无论表是否采用分区,都可以对表采用全局索引分区。此外,不能对cluster表,位图索引采用全局索引分区。
create index index_saleprice on books(saleprice)
global partition by range(saleprice) --global 全局的,全域的
(
partition p1 values less than (30),
partition p2 values less than (50),
partition p3 values less than (maxvalue)
)
create index index_ISBN on books(ISBN)
global partition by hash(ISBN);
评论
有用 3
墨值悬赏


