Using Oracle Data Storage Structures Efficiently

1.创建集群表

create cluster mycluster (deptno number(2)) size 1024;

]

 

2.为集群表创建索引

create index myc_idx on cluster mycluster;

 

3.创建普通表与集群表关联

create table dept(

 deptid number(2) primary key,

 dname varchar2(20),

 loc varchar2(30)

)

cluster mycluster(deptid);

 

create table emp(

empid number primary key,

ename varchar2(20),

sal number,

deptno number(2) references dept(deptid)

)

cluster mycluster(deptno)

 

修正

SQL > 4 修改第四行

SQL > c/number/number, 修改number为number,

 

4.创建partition 表

create table kk(

rk date,

data varchar2(20)

)

partition by range(rk)(

partition p1 values less than (to_date('2009-01-01','yyyy-mm-dd')) tablespace ts0,

partition p2 values less than ((to_date('2010-01-01','yyyy-mm-dd')) tablespace ts1

);

 

5.查看记录

select * from kk partition(p1);

 

6.涵盖所有记录

alter table kk add partition  p3 values less than (MAXVALUE) tablespace ts2;

 

7.创建Hash Partition 表

create table emp(

empno number,

ename varchar2(20)

)

partition by hash(empno)(

partition part1 tablespace ts1,

partition part2 tablespace ts2

);

 

8.创建List partition表

create table locations(

location_id number,

street_address varchar2(40),

city varchar2(20),

state_province(30),

country_id number)

) tablespace users

partition by LIST (state_province)

(partition region_east values('MA','NY','CT','ME','MD'),

partition  region_west values('CA','ZA'),

partition region_south values('TX','KY'),

partition region_default values(default)

 

9.创建组合分区表

create table composite1(

range_key date,

hash_key int,

data varchar2(20)

)

partition by range(range_key)

subpartition by hash(hash_key) subpartitions 2

(

  partition part1 values less than((to_date('2008-01-01','yyyy-mm-dd'))

  (

    subpartition h1,

    subpartition h2

  ),

 partition part2 values less than(to_date('2009-01-01','yyyy-mm-dd'))

 (

   subpartition h22,

   subpartition h21

 )

)

 

10.创建分区表索引

 1.local index

create index local_index on table1(a,b) local;

 

2.global index

 create index global_index on table1(b) global

partition by range(b)

(

 partition idx1 values less than (1000),

 partition idx2 values less than (MAXVALUE)

);

 

11.移动表

 alter table hr.employees move tablespace users;

 

12.压缩索引

 create index emp_index on hr.employee (last_name,first_name) compress.

 

alter index emp_index rebuild compress;

 

13. IOT表

create table T(id int primary key,

 y varchar2(2000),

 z varchar2(2000)

) organization index

pctthreshold 20/including y

overflow tablespace users;

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值