Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3540967
  • 博文数量: 715
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7745
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(715)

文章存档

2023年(75)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

最近访客

分类: Oracle

2009-06-01 12:07:53

 
练习 oracle exchange partition
--创建分区表 t1
create tablespace tsa datafile 'c:\tsa.dbf' size 10m;
create tablespace tsa_p0 datafile 'c:\tsa_p0.dbf' size 40m;
create tablespace tsa_p1 datafile 'c:\tsa_p1.dbf' size 40m;
create tablespace tsa_p2 datafile 'c:\tsa_p2.dbf' size 40m; 
--drop table t1;
--truncate table t1;
create table t1 partition by list (object_type)
(partition p1 values ('SYNONYM') tablespace tsa_p1,
partition p2 values ('JAVA CLASS') tablespace tsa_p2,
partition p0 values (default) tablespace tsa_p0
) as select * from dba_objects where 1=2;
 
--创建普通表 t2
create tablespace tsb datafile 'c:\tsb01.dbf' size 100m;
--drop table t2;
create table t2 tablespace tsb as select * from dba_objects where 1=2;
--truncate table t2;
declare
  i number;
begin
-- 灌入数据 30万条 34M
  for i in 1 .. 15 loop
   insert into t2 select * from dba_objects where object_type='SYNONYM';
    commit;
  end loop;
end;
/
 
-- 检查当前使用情况
select owner,segment_name,partition_name,segment_type,tablespace_name,bytes
from dba_segments where owner='A' order by 1,2,3 ;

--交换分区
alter table t1 exchange partition p1 with table t2;
 
--再查看
select owner,segment_name,partition_name,segment_type,tablespace_name,bytes
from dba_segments where owner='A' order by 1,2,3 ;

--再执行一次exchange 又会回复原先的表空间使用情况。
阅读(4524) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~