Cluster Tables

 

Cluster Tables

一、         Cluster table创建语法

 

1Creating Clusters

CREATE CLUSTER emp_dept (deptno NUMBER(3))

   SIZE 600

   TABLESPACE users

   STORAGE (INITIAL 200K

      NEXT 300K

      MINEXTENTS 2

      PCTINCREASE 33);

2Creating Clustered Tables

CREATE TABLE dept (

   deptno NUMBER(3) PRIMARY KEY, . . . )

   CLUSTER emp_dept (deptno);

3Creating Cluster Indexes

CREATE INDEX emp_dept_index

   ON CLUSTER emp_dept

   TABLESPACE users

   STORAGE (INITIAL 50K

      NEXT 50K

      MINEXTENTS 2

      MAXEXTENTS 10

      PCTINCREASE 33);

 

二、实验分析

 

1、创建cluster,indexcluster table

sys@TEST> create cluster cluster_doudou

  2  (deptid number(2))

  3  size 1024

  4  /

Cluster created.

sys@TEST> create index cluster_doudou_index on cluster cluster_doudou;

Index created.

sys@TEST> create table cluster_01

  2  (deptid number(2) primary key,

  3  name varchar2(2) ) cluster cluster_doudou(deptid);

Table created.

 

2、分析cluster table使用条件(权限暂不考虑)

创建cluster table定义中,不使用cluster中的列(deptid),创建失败

sys@TEST> create table cluster_02 (name varchar2(2),dd number(2)) cluster cluster_doudou(deptid);

create table cluster_02 (name varchar2(2),dd number(2)) cluster cluster_doudou(deptid)

*

ERROR at line 1:

ORA-00945: specified clustered column does not exist

sys@TEST> create table cluster_02

  2  (deptid number(2), name varchar2(2) ) cluster cluster_doudou(deptid);

Table created.

 

创建cluster table定义中,使用deptid,但是定义的类型不同,创建失败

sys@TEST>  create table cluster_03 (deptid varchar2(20) , name varchar2(2) ) cluster cluster_doudou(deptid);

 create table cluster_03 (deptid varchar2(20) , name varchar2(2) ) cluster cluster_doudou(deptid)                                                                                      *

ERROR at line 1:

ORA-01753: column definition incompatible with clustered column definition

sys@TEST> create table cluster_03

  2  (name varchar2(20),deptid number(2)) cluster cluster_doudou(deptid);

Table created.

 

三、         总结

 

1create cluster table的时候,语法中必须包含cluster中的列deptid

2cluster中列deptid定义类型(deptid NUMBER(2))必须相同

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值