技术开发 频道

ORACLE分区表的操作应用

    3.分区表的数据交换

    分区表和普通表的数据交换有个严格的要求,就是普通表的结构和分区表的列相同,而且主键也相同,并且不能有外键约束,如果有,数据表要为空;

Alter table dinya_test change partition part_01 with table t_comm

    这里t_comm与分区表的结构是一样的;

    4. 分区表索引的使用:

    分区表和一般表一样可以建立索引,分区表可以创建局部索引和全局索引。当分区中出现许多事务并且要保证所有分区中的数据记录的唯一性时采用全局索引。(但是位图索引是一定要建成局部索引的.)

    4.1. 局部索引分区的建立:

SQL> create index dinya_idx_t on dinya_test(item_id) 2 local 3 ( 4 partition idx_1 tablespace dinya_space01, 5 partition idx_2 tablespace dinya_space02, 6 partition idx_3 tablespace dinya_space03 7 ); Index created. SQL>

    或者按下面的方法建立也可以

create index dinya_idx_t on dinya_test(item_id) local

    4.2. 全局索引分区的建立

    全局索引建立时global 子句允许指定索引的范围值,这个范围值为索引字段的范围值:

SQL> create index dinya_idx_t on dinya_test(item_id) 2 local 3 ( 4 partition idx_1 tablespace dinya_space01, 5 partition idx_2 tablespace dinya_space02, 6 partition idx_3 tablespace dinya_space03 7 ); Index created. SQL>后者如下面的建立也可以 SQL> create index dinya_idx_t on dinya_test(item_id);
0
相关文章