溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

分區交換 alter table exchange partition 在線表 歷史表交換

發布時間:2020-10-03 17:49:18 來源:網絡 閱讀:1000 作者:JUN_LJ 欄目:關系型數據庫

創建表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



向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女