ORACLE基础操作【01】 -->MOVE 分区表
2015-05-04 22:52
761 查看
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production --不含有子分区的分区表操作 SQL> create table pt1( 2 object_id number, 3 status varchar2(8) 4 ) 5 partition by range(object_id) 6 ( 7 partition p01 values less than (10000), 8 partition p02 values less than (20000), 9 partition p03 values less than (30000), 10 partition pmax values less than (maxvalue) 11 ); Table created. SQL> insert into pt1 2 select object_id,status from dba_objects; 71937 rows created. SQL> commit; Commit complete. --创建分区索引 SQL> create index idx_pt1 on pt1(object_id) local; Index created. SQL> select INDEX_NAME,PARTITION_NAME,STATUS from dba_ind_partitions where index_owner='AIKI' 2 SQL> . SQL> / INDEX_NAME PARTITION_NAME STATUS ------------------------------ ------------------------------ -------- IDX_PT1 PMAX USABLE IDX_PT1 P03 USABLE IDX_PT1 P02 USABLE IDX_PT1 P01 USABLE SQL> alter table pt1 move partition p01 tablespace tartbs; Table altered. INDEX_NAME PARTITION_NAME STATUS ------------------------------ ------------------------------ -------- IDX_PT1 PMAX USABLE IDX_PT1 P03 USABLE IDX_PT1 P02 USABLE IDX_PT1 P01 UNUSABLE SQL> alter table pt1 move partition p01 tablespace tartbs update indexes; Table altered. 1* select INDEX_NAME,PARTITION_NAME,STATUS from dba_ind_partitions where index_owner='AIKI' SQL> / INDEX_NAME PARTITION_NAME STATUS ------------------------------ ------------------------------ -------- IDX_PT1 PMAX USABLE IDX_PT1 P03 USABLE IDX_PT1 P02 USABLE IDX_PT1 P01 USABLE SQL> alter table pt1 move partition p01 tablespace tartbs nologging compress update indexes; Table altered. SQL> alter table pt1 move partition p01 tablespace tartbs nologging compress update indexes parallel 4; Table altered. SQL> drop index idx_pt1; Index dropped. Elapsed: 00:00:00.06 SQL> SQL> create index idx_pt1 on pt1(object_id); Index created. Elapsed: 00:00:00.08 SQL> alter table pt1 move partition p01 tablespace tartbs; Table altered. Elapsed: 00:00:00.05 INDEX_NAME DEGREE STATUS ------------------------------ ---------------------------------------- -------- IDX_PT1 1 UNUSABLE SQL> alter table pt1 move partition p01 tablespace tartbs update indexes; Table altered. INDEX_NAME DEGREE STATUS ------------------------------ ---------------------------------------- -------- IDX_PT1 1 UNUSABLE SQL> alter table pt1 move partition p01 tablespace tartbs update global indexes; Table altered. INDEX_NAME DEGREE STATUS ------------------------------ ---------------------------------------- -------- IDX_PT1 1 UNUSABLE --可以在move table后再单独的rebuild index SQL> ALTER INDEX idx_pt1 REBUILD tablespace tartbs; Index altered. INDEX_NAME DEGREE STATUS ------------------------------ ---------------------------------------- -------- IDX_PT1 1 VALID --对于分区表的语法为: SQL> alter index idx_pt1 rebuild partition p02 tablespace tartbs parallel 4; Index altered. SQL> drop table pt1 purge; Table dropped. --move含有子分区的表 SQL> create table subpt1( 2 object_id number, 3 status varchar2(8) 4 ) 5 partition by range(object_id) 6 subpartition by list(status) 7 ( 8 partition pt1 values less than(10000) 9 ( 10 subpartition subpt1 values('VALID'), 11 subpartition subpt2 values('INVALID') 12 ), 13 partition pt2 values less than(20000) 14 ( 15 subpartition subpt3 values('VALID'), 16 subpartition subpt4 values('INVALID') 17 ), 18 partition pt3 values less than(30000) 19 ( 20 subpartition subpt5 values('VALID'), 21 subpartition subpt6 values('INVALID') 22 ), 23 partition pmax values less than(maxvalue) 24 ( 25 subpartition subpt7 values('VALID'), 26 subpartition subpt8 values('INVALID') 27 ) 28 ); Table created. SQL> insert into subpt1 select object_id,status from dba_objects; 71931 rows created. SQL> commit; Commit complete. SQL> update subpt1 set status='INVALID' where object_id between 0 and 10000 and rownum<100; update subpt1 set status='INVALID' where object_id between 0 and 10000 and rownum<100 * ERROR at line 1: ORA-14402: updating partition key column would cause a partition change SQL> alter table subpt1 enable row movement; Table altered. SQL> update subpt1 set status='INVALID' where object_id between 0 and 10000 and rownum<100; 99 rows updated. SQL> update subpt1 set status='INVALID' where object_id between 10000 and 20000 and rownum<100; 99 rows updated. SQL> update subpt1 set status='INVALID' where object_id between 20000 and 30000 and rownum<100; 99 rows updated. Index created. PARTITION_NAME SUBPARTITION_NAME STATUS ------------------------------ ------------------------------ -------- PT1 SUBPT1 USABLE PT1 SUBPT2 USABLE PT2 SUBPT3 USABLE PT2 SUBPT4 USABLE PT3 SUBPT5 USABLE PT3 SUBPT6 USABLE PMAX SUBPT7 USABLE PMAX SUBPT8 USABLE SQL> alter table subpt1 move subpartition subpt2 tablespace tartbs; Table altered. PARTITION_NAME SUBPARTITION_NAME STATUS ------------------------------ ------------------------------ -------- PT1 SUBPT1 USABLE PT1 SUBPT2 UNUSABLE PT2 SUBPT3 USABLE PT2 SUBPT4 USABLE PT3 SUBPT5 USABLE PT3 SUBPT6 USABLE PMAX SUBPT7 USABLE PMAX SUBPT8 USABLE SQL> alter index idx_subpt1 rebuild subpartition subpt2 tablespace tartbs; Index altered. PARTITION_NAME SUBPARTITION_NAME STATUS ------------------------------ ------------------------------ -------- PT1 SUBPT1 USABLE PT1 SUBPT2 USABLE PT2 SUBPT3 USABLE PT2 SUBPT4 USABLE PT3 SUBPT5 USABLE PT3 SUBPT6 USABLE PMAX SUBPT7 USABLE PMAX SUBPT8 USABLE SQL> alter table subpt1 move subpartition subpt2 tablespace tartbs compress; Table altered. SQL> alter table subpt1 move subpartition subpt2 tablespace tartbs nologging compress; alter table subpt1 move subpartition subpt2 tablespace tartbs nologging compress * ERROR at line 1: ORA-14160: this physical attribute may not be specified for a table subpartition 详情参见:8-39(p641)<sql language> NOLOGGING is supported in only a subset of the locations that support LOGGING. Only the following operations support the NOLOGGING mode: SQL> alter index idx_subpt1 rebuild subpartition subpt2 tablespace tartbs; Index altered.
相关文章推荐
- ORACLE基础操作【02】 -->split分区表
- <<Oracle Applications DBA 基础(第二期)>>Week 01 exercise
- <<Oracle Applications DBA 基础(第二期)>>Week 13 exercise
- [原]java专业程序代写(qq:928900200),学习笔记之基础入门<Oracle_基础>(三十三)
- <<Oracle Applications DBA 基础(第二期)>>Week 02 exercise
- 原创: Oracle的远程数据库的连接和用户操作 <三>
- Git基础操作<三>
- Oracle EBS 寄销/VMI(3)-->基础设置补充
- <<Oracle Applications DBA 基础(第二期)>>Week 03 exercise
- 原创:oracle PL/SQL编程基础 上<十一>
- Dojo 的文档操作基础二<9>
- Git基础操作<一>
- <<Oracle Applications DBA 基础(第二期)>>Week 06 exercise
- <<Oracle Applications DBA 基础(第二期)>>Week 15 exercise
- [原]java专业程序代写(qq:928900200),学习笔记之基础入门<Oracle_函数_触发器_游标_存储过程_视图>(三十五)
- 原创:oracle PL/SQL编程基础 下<十二>
- <PY><Oracle>Windows下cx_Oracle配置 操作SQL
- <<Oracle Applications DBA 基础(第二期)>>Week 05 exercise
- Oracle-->基础知识-->Oracle 数据库目录 ORACLE_BASE ORACLE_HOME