--------1.添加分区(以下代码给sales表添加了一个p3分区)
alter table sales add partition p3 values less than(to_date(‘2003-06-01‘,‘yyyy-mm-dd‘));
alter table sales modify partition p3 add subpartition p3sub1 values(‘complete‘);
--------2.删除分区(以下代码删除了p3表分区):
alter table sales drop partition p3;
alter table sales drop subpartition p4sub1;
--------3.截断分区
alter table sales truncate partition p2;
alter table sales truncate subpartition p2sub2;
--------4.合并分区
alter table sales merge partitions p1,p2 into partition p2;
--------5 拆分分区
alter table sales sblit partition p2 at(to_date(‘2003-02-01‘,‘yyyy-mm-dd‘)) into (partition p21,partition p22);
--------6 接合分区(接合分区只能用于散列分区中)
alter table sales coalesca partition;
--------7.重命名表分区
alter table sales rename partition p21 to p2;
--------8 相关查询
--跨分区查询
--查询表上有多少分区
select * from user_tab_partitions where table_name=‘AC01‘;
--查询索引信息
select object_name, object_type, tablespace_name, sum(value)
from v$segment_statistics
where statistic_name IN
(‘physical reads‘, ‘physical write‘, ‘logical reads‘)
and object_type = ‘INDEX‘
group by object_name, object_type, tablespace_name
order by 4 desc;
--显示分区表信息:
select * from dba_part_tables;
select * from all_part_tables;
select * from user_part_tables;
--显示分区信息:
select * from dba_tab_partitions;
select * from all_tab_partitions;
select * from user_tab_partitions;
--显示子分区信息
select * from dba_tab_subpartitions;
select * from all_tab_subpartitions;
select * from user_tab_subpartitions;
--显示分区列信息:
select * from dba_part_key_columns;
select * from all_part_key_columns;
select * from user_part_key_columns;
--显示子分区列信息:
select * from dba_subpart_key_columns;
select * from all_subpart_key_columns;
select * from user_subpart_key_columns;
--怎样查询出oracle数据库中所有的的分区表
select * from user_tables a where a.partitioned=‘YES‘
--删除一个表的数据是
truncate table table_name;
--删除分区表一个分区的数据是
alter table table_name truncate partition p5;