oracle分区表带入SQL语句,Oracle 分区表常用SQL语句 (转载)
*********
為分區表建立一個單獨的表空間
*********/create tablespace ts_partition datafile '/home/oracle/oradata/esales/partition.dbf' size 10M
extent management local uniform size 2M;
/*********
建立分區表
*********/create table bigtable
(
sale_date date,
product_id number,
sale_count number,
charge number,
sales_id number
)
tablespace ts_partition
pctfree 5
pctused 80
initrans 1
maxtrans 255
parallel(degree 2)
storage
(
initial 2M
next 2M
minextents 1
maxextents unlimited
pctincrease 0
)
partition by range(sale_date)
(
partition sale_date_20020101 values less than (to_date('20020102','yyyymmdd')),
partition sale_date_20020102 values less than (to_date('20020103','yyyymmdd'))
);
/*********
建立分區索引
*********/create index create index idx_bigtable_product_id on bigtable(product_id) parallel 2 local
tablespace users on bigtable(product_id) parallel 2 local tablespace users;
/*********
增加分區
*********/alter table bigtable add partition sale_date_20020103
values less than (to_date('20020104','yyyymmdd'));
/*********
截斷分區
*********/alter table bigtable truncate partition sale_date_20020103;
/*********
丟棄分區
*********/alter table bigtable drop partition sale_date_20020103;
/*********
交換分區
如果分區表里含有 LOCAL 的索引,此分區的索引將處于不可用狀態,需要重建:
alter index idx_bigtable_product_id rebuild partition sale_date_20020102 tablespace users;
如果被交換表和分區表的索引結構相同,可以用 including indexes 連同索引一起交換,不必重建索引。
*********/create table bigtable_temp tablespace users as select * from bigtable where 1=2;
insert into bigtable_temp values (to_date('20020102','yyyymmdd'),1,10,1,10);
commit;
alter table bigtable exchange partition sale_date_20020102 with table bigtable_temp;
/*********
移動分區
*********/alter table bigtable move partition sale_date_20020102 tablespace user2;
/*********
修改分區
*********/alter table bigtable modify partition
sale_date_20020102 storage(pctincrease 10);
/*********
重命名分區
*********/alter table bigtable rename partition
sale_date_20020102 to sale_date_20020103;
/*********
分割分區
*********/alter table bigtable add partition sale_date_20020104
values less than (to_date('20020105','yyyymmdd'));
alter table bigtable split partition sale_date_20020104
at (to_date('20020104','yyyymmdd'))
into (partition sale_date_20020103,partition sale_date_20040104);
/*********分區表數據的邏輯備份exp username/password file=bigtable20020103_4.dmp tables=(bigtable:sale_date_20020103,bigtable:sale_date_20020104)分區表數據的邏輯恢復imp username/password file=bigtable20020103_4.dmp tables=(bigtable:sale_date_20020103,bigtable:sale_date_20020104) ignore=y*********/
總結
以上是生活随笔為你收集整理的oracle分区表带入SQL语句,Oracle 分区表常用SQL语句 (转载)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 买WATCH系列还是GT系列?5款热销华
- 下一篇: mysql -b -e_MySQL 的B