分区交换 alter table exchange partition 在线表 历史表交换
2017-08-01 18:05
615 查看
创建表test_part_1 默认为users表空间:
create table test_part_1(a number, b number)
partition by range(a)
(
partition p1 values less than (10),
partition p2 values less than (20),
partition p3 values less than (30),
partition p4 values less than (40)
);
创建test_part_1 本地索引
create index idx_id on test_part_1(a) local tablespace TS_KSZIP_BASE;
--插入记录
insert into test_part_1 values(1,2);
insert into test_part_1 values(11,2);
insert into test_part_1 values(21,2);
insert into test_part_1 values(31,2);
commit;
--查看记录
select rowid from test_part_1 where a=1;--AAAlz4AAEAAFTUEAAA 查询1
--创建中间表
create table test_part_3(a number, b number);
create index idx_id3 on test_part_3(a);--默认表空间users
--test_part_1 与中间表交换
alter table test_part_1 exchange partition p1 with table test_part_3 including indexes with validation; --目标表有数据不能交换,交换只能是分区和非分区表交换
--验证
select * from dba_ind_partitions where index_name=upper('idx_id');--p1的表空间变成了users,并且状态为usable,不用rebuild
select * from dba_indexes where index_name=upper('idx_id3');--表空间变成了TS_KSZIP_BASE.
select rowid from test_part_3;--AAAlz4AAEAAFTUEAAA 跟查询1对比可见 只是改了数据字典
--创建 目标分区表test_part_2
create table test_part_2(a number, b number)
partition by range(a)
(
partition p1 values less than (10),
partition p2 values less than (20),
partition p3 values less than (30),
partition p4 values less than (40),
partition p5 values less than (50)
);
create index idx_id2 on test_part_2(a) local tablespace TS_KSZIP_BASE;
alter table test_part_2 exchange partition p1 with table test_part_3 including indexes with validation; --目标表有数据不能交换,交换只能是分区非分区交换
select * from dba_ind_partitions where index_name=upper('idx_id2');--索引p1可用,表空间依然是TS_KSZIP_BASE(因为此时 idx_id3表空间为TS_KSZIP_BASE)
select * from dba_indexes where index_name=upper('idx_id3');--表空间为TS_KSZIP_BASE,状态也是usable
create table test_part_1(a number, b number)
partition by range(a)
(
partition p1 values less than (10),
partition p2 values less than (20),
partition p3 values less than (30),
partition p4 values less than (40)
);
创建test_part_1 本地索引
create index idx_id on test_part_1(a) local tablespace TS_KSZIP_BASE;
--插入记录
insert into test_part_1 values(1,2);
insert into test_part_1 values(11,2);
insert into test_part_1 values(21,2);
insert into test_part_1 values(31,2);
commit;
--查看记录
select rowid from test_part_1 where a=1;--AAAlz4AAEAAFTUEAAA 查询1
--创建中间表
create table test_part_3(a number, b number);
create index idx_id3 on test_part_3(a);--默认表空间users
--test_part_1 与中间表交换
alter table test_part_1 exchange partition p1 with table test_part_3 including indexes with validation; --目标表有数据不能交换,交换只能是分区和非分区表交换
--验证
select * from dba_ind_partitions where index_name=upper('idx_id');--p1的表空间变成了users,并且状态为usable,不用rebuild
select * from dba_indexes where index_name=upper('idx_id3');--表空间变成了TS_KSZIP_BASE.
select rowid from test_part_3;--AAAlz4AAEAAFTUEAAA 跟查询1对比可见 只是改了数据字典
--创建 目标分区表test_part_2
create table test_part_2(a number, b number)
partition by range(a)
(
partition p1 values less than (10),
partition p2 values less than (20),
partition p3 values less than (30),
partition p4 values less than (40),
partition p5 values less than (50)
);
create index idx_id2 on test_part_2(a) local tablespace TS_KSZIP_BASE;
alter table test_part_2 exchange partition p1 with table test_part_3 including indexes with validation; --目标表有数据不能交换,交换只能是分区非分区交换
select * from dba_ind_partitions where index_name=upper('idx_id2');--索引p1可用,表空间依然是TS_KSZIP_BASE(因为此时 idx_id3表空间为TS_KSZIP_BASE)
select * from dba_indexes where index_name=upper('idx_id3');--表空间为TS_KSZIP_BASE,状态也是usable
相关文章推荐
- oracle分区表之交换分区 altertable exchange partition with table
- oracle分区表之交换分区 altertable exchange partition with table
- oracle分区表之交换分区 altertable exchange partition with table
- oracle分区表之交换分区 altertable exchange partition with table
- oracle分区表之交换分区 altertable exchange partition with table
- ORA-14097: column type or size mismatch in ALTER TABLE EXCHANGE PARTITION
- mysql partition(mysql range partition,对历史数据建分区)
- Oracle用分区表分区交换做历史数据迁移
- [原]使用Oracle Partition Table对日志表进行分区一例
- hive中简单介绍分区表(partition table),含动态分区(dynamic partition)与静态分区(static partition)
- hive中简单介绍分区表(partition table),含动态分区(dynamic partition)与静态分区(static partition)
- 分区范围oracle partition table related operations
- MySQL 表分区 报错:Table has no partition for value XXX
- Oracle用分区表分区交换做历史数据迁移
- [Hive - LanguageManual] Alter Table/Partition/Column
- 普通表转分区表(交换分区、在线重定义)
- 利用EXCHANGE PARTITION WITH TABLE方式进行数据归档
- 分区交换exchange
- Linux's swap space partition(交换分区)
- 普通表转分区表(交换分区、在线重定义)