ITPub博客

首页 > 数据库 > Oracle > Oracle Cluster Tables

Oracle Cluster Tables

原创 Oracle 作者:lovehewenyu 时间:2012-11-14 16:10:18 0 删除 编辑

Cluster Tables

一、          Cluster table 创建语法

 

1 、 Creating Clusters

CREATE CLUSTER emp_dept ( deptno NUMBER(3))

   SIZE 600

   TABLESPACE users

   STORAGE (INITIAL 200K

      NEXT 300K

      MINEXTENTS 2

      PCTINCREASE 33);

2 、 Creating Clustered Tables

CREATE TABLE dept (

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

   CLUSTER emp_dept (deptno);

3 、 Creating 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,index , cluster 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.

 

三、          总结

 

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

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

 

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26442936/viewspace-749216/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
10年金融行业老鸟。Oracle,Mysql,PostgreSQL,EMC 存储,NBU备份。微信/电话 18211103995

注册时间:2012-02-03

  • 博文量
    307
  • 访问量
    1528515