Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Partition switching alter table exchange partition on-line table history table exchange

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Create table test_part_1 Default to users Tablespace:

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)

);

Create test_part_1 local index

create index idx_id on test_part_1(a) local tablespace TS_KSZIP_BASE;

--Insert record

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;

--View records

select rowid from test_part_1 where a=1;--AAAlz4AAEAAFTUEAAA Inquiry 1

--Create intermediate table

create table test_part_3(a number, b number);

create index idx_id3 on test_part_3(a);--default table space users

--test_part_1 exchanges with intermediate tables

alter table test_part_1 exchange partition p1 with table test_part_3 including indexes with validation; --Target table has data cannot be exchanged, exchange can only be partitioned and non-partitioned table exchange

--Verification

select * from dba_ind_partitions where index_name=upper ('idx_id');--p1's table space becomes users and the state is unusable, no rebuild required

select * from dba_indexes where index_name=upper ('idx_id3');--Tablespace becomes TS_KSZIP_BASE.

select rowid from test_part_3;--AAAlz4AAEAAFTUEAAA Compared with query 1 Visible only changed data dictionary

--Create target partition table 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; --Target table has data that cannot be exchanged, exchange can only be partition non-partition exchange

select * from dba_ind_partitions where index_name=upper ('idx_id2');--index p1 is available, table space is still TS_KSZIP_BASE(because idx_id3 table space is TS_KSZIP_BASE)

select * from dba_indexes where index_name=upper ('idx_id3');--Tablespace is TS_KSZIP_BASE, status is also usable

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 248

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report