一、创建表空间
create tablespace dinya_space01 datafile 'f:\user_data1.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
create tablespace dinya_space02 datafile 'f:\user_data2.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
create tablespace dinya_space03 datafile 'f:\user_data3.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
create tablespace dinya_space04 datafile 'f:\user_data4.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
二、删除表空间并删除文件
DROP TABLESPACE dinya_space01 INCLUDING CONTENTS and datafiles;
DROP TABLESPACE dinya_space02 INCLUDING CONTENTS and datafiles;
DROP TABLESPACE dinya_space03 INCLUDING CONTENTS and datafiles;
DROP TABLESPACE dinya_space04 INCLUDING CONTENTS and datafiles;
三、创建分区表
create table Partition_Test
(
PID number not null,
PITEM varchar2(200),
PDATA date not null
)
partition by range(PDATA)
(
partition part_t01 values less than(to_date('2004-01-01','yyyy-mm-dd')) tablespace dinya_space01,
partition part_t02 values less than(to_date('2008-01-01','yyyy-mm-dd')) tablespace dinya_space02
) ;
四、增加一个分区
alter table Partition_Test add partition part_t03 values less than (to_date('2010-01-01','yyyy-mm-dd')) tablespace dinya_space03;
五、向分区表中插入数据
insert into Partition_Test(PID,PITEM,PDATA) values(1,'2323',to_date('2009-01-05','yyyy-mm-dd')) ;
六、查询数据
select * from Partition_Test partition(part_t02) t where t.pid = 1 ;
七、更新数据
update Partition_Test partition(part_t03) t set t.PITEM = 'JZHUA' where t.pid = 1;
八、删除数据
delete from Partition_Test partition(part_t03) t where t.pid = 1;
九、删除分区
alter table Partition_Test drop partition part_t03;