oracle根據已有表及資料建立表分割槽並匯入資料
假設情景:
現有system.test表,資料量過千萬,處於ts_test表空間中。
表中有列a,將a=6與a小於6的資料進行分割槽
www.2cto.com
確保不會有外部程式修改需要建表分割槽的表
1. 對需要重建表分割槽的表進行備份,匯出dmp,防止資料丟失
sql**
exp 使用者名稱/密碼@tns名 file=c:/test.dmp log=c:/test.log full=n rows=y buffer=10240000 tables=system.test
2. 建立臨時表,用來回導資料
sql**
create table system.test_bak
tablespace ts_test
as
select * from system.test;
3. 校驗資料行數 www.2cto.com
sql**
select count('x') c1 from system.test;
select count('x') c2 from system.test_bak;
如果行數不一致需查詢原因
4. 重建表
sql**
truncate table system.test;
drop table system.test;
sql**
create table system.test
tablespace ts_test
partition by range(a)
( partition p1 values less than ('6')
tablespace ts_test
, partition p2 values less than ('7')
tablespace ts_test,
partition p3 values less than (maxvalue)
tablespace ts_test
) as
select
from system.test_bak;
第4步執行完之後,表裡的資料就分散到了p1和p2分割槽中
www.2cto.com
5. 重建索引,將原有表中的索引再建到system.test表中。
6. 檢查分割槽
sql**
select decode(a,'1','1','2','1','3','1','4','1','5','1',a),
count('x') n
from system.test
group by decode(a,'1','1','2','1','3','1','4','1','5','1',a)
order by decode(a,'1','1','2','1','3','1','4','1','5','1',a);
select count('x') n1 from system.test partition (p1);
ORACLE將已有表分割槽
以table name內容建立分割槽表table name1並將資料寫入 create table table name1 partition by range createdate partition table name p1 values less than to date 2018 1 1 ...
oracle根據已有表及資料建立表分割槽並匯入資料
假設情景 現有system.test表,資料量過千萬,處於ts test表空間中。表中有列a,將a 6與a小於6的資料進行分割槽 確保不會有外部程式修改需要建表分割槽的表 1.對需要重建表分割槽的表進行備份,匯出dmp,防止資料丟失 exp 使用者名稱 密碼 tns名 file c test.dmp...
Oracle建立表空間 表分割槽
建立表分割槽 create tablespace ts demo datafile oracle2 oracle datafile xltsdemo.dbf size 500m 初始大小 autoextend on 可以自動擴充套件 next 50m 一次擴充套件50m maxsize unlimi...