【转载】Oracle表介绍--簇表
来源:互联网 发布:win10 mac 双系统 编辑:程序博客网 时间:2024/06/06 04:08
簇和簇表
簇其实就是一组表,是一组共享相同数据块的多个表组成。 将经常一起使用的表组合在一起成簇可以提高处理效率。
在一个簇中的表就叫做簇表。建立顺序是:簇→簇表→数据→簇索引
1、创建簇的 格式
CREATE CLUSTER cluster_name
(column date_type [,column datatype]...)
[PCTUSED 40 | integer] [PCTFREE 10 | integer]
[SIZE integer]
[INITRANS 1 | integer] [MAXTRANS 255 | integer]
[TABLESPACE tablespace]
[STORAGE storage]
(column date_type [,column datatype]...)
[PCTUSED 40 | integer] [PCTFREE 10 | integer]
[SIZE integer]
[INITRANS 1 | integer] [MAXTRANS 255 | integer]
[TABLESPACE tablespace]
[STORAGE storage]
SIZE:指定估计平均簇键,以及与其相关的行所需的字节数。
2、创建簇
create cluster my_clu (deptno number ) pctused 60 pctfree 10 size 1024 tablespace users storage ( initial 128 k next 128 k minextents 2 maxextents 20
);
3、创建簇表
create table t1_dept( deptno number , dname varchar2 ( 20 ) ) cluster my_clu(deptno); create table t1_emp( empno number , ename varchar2 ( 20 ), birth_date date , deptno number )
cluster my_clu(deptno);
4、为簇创建索引
create index clu_index on cluster my_clu;
注:若不创建索引,则在插入数据时报错:ORA-02032: clustered tables cannot be used before the cluster index is built
管理簇
使用ALTER修改簇属性(必须拥有ALTER ANY CLUSTER的权限)
1、修改簇属性
可以修改的簇属性包括:
* PCTFREE、PCTUSED、INITRANS、MAXTRANS、STORAGE
* 为了存储簇键值所有行所需空间的平均值SIZE
* 默认并行度
注:
* 不能修改INITIAL和MINEXTENTS的值
* PCTFREE、PCTUSED、SIZE参数修改后适用于所有数据块
* INITRANS、MAXTRANS仅适用于以后分配的数据块
* STORAGE参数修改后仅影响以后分配给簇的盘区
格式:
alter cluster my_clu
pctused 40
2、删除簇
drop cluster my_clu; -- 仅适用于删除空簇
drop cluster my_clu including tables ; -- 删除簇和簇表
drop cluster my_clu including tables cascade constraints ;
-- 同时删除外键约束
注:簇表可以像普通表一样删除。
散列聚簇表
在簇表中,Oracle使用存储在索引中的键值来定位表中的行,而在散列聚簇表中,使用了散列函数代替了簇索引,先通过内部函数或者自定义的函数进行散列计算,然后再将计算得到的码值用于定位表中的行。创建散列簇需要用到HASHKEYS子句。
1、创建散列簇
create cluster my_clu_two(empno number(10) ) pctused 70 pctfree 10 tablespace users hash is empno
hashkeys 150 ;
说明:
* hash is 子句指明了进行散列的列,如果列是唯一的标示行,就可以将列指定为散列值
* hashkeys 指定和限制散列函数可以产生的唯一的散列值的数量
2、创建散列表
create table t2_emp ( empno number ( 10 ), ename varchar2 ( 20 ), birth_date date , deptno number )
cluster my_clu_two(empno);
注意:
* 必须设置数值的精度(具体原因不详)
* 散列簇不能也不用创建索引
* 散列簇不能ALTER:size、hashkeys、hash is参数
- 【转载】Oracle表介绍--簇表
- oracle表介绍--簇表
- Oracle表介绍--簇表
- ORACLE数据库PROC编程经验介绍(转载)
- Oracle 8 的函数介绍[转载]
- Oracle中有关Latch的介绍(转载)
- 2.Oracle:Oracle中dual表的用途介绍(转载)
- oracle表分区(转载)
- oracle/mssql 复制表 (转载)
- Oracle 表的介绍
- Oracle 表空间介绍
- oracle临时表介绍
- oracle 系统表介绍
- oracle 表压缩 介绍
- ORACLE表空间介绍
- Oracle外部表介绍.
- Oracle表空间介绍
- oracle 转载
- 理解 pkg-config 工具
- macro `AM_PROG_LIBTOOL’ not found in library
- C中的volatile用法
- list files
- Compromise(最长公共子串变形,打印路径)
- 【转载】Oracle表介绍--簇表
- 【转载】Oracle中的OOP概念
- 【转】什么情况会导致Oracle数据库的全表扫描
- 【转】用ExtJS 实现动态载入树(Load tree)
- EXTJS File控件+common FileUpload上传文件
- smartupload实现文件下载
- jquery树入门实例
- Extjs 关于动态显示TextField
- JQuery Datagrid 入门例子