易截截图软件、单文件、免安装、纯绿色、仅160KB

Oracle的聚簇表

索引聚簇表
create cluster emp_dept_cluster
(deptno number(2)) size 1024;
size 1024 表示每个聚簇键值关联大约1024字节的数据,
oracle会在用这个数据库块上通过size计算最多可以放多少个簇
如果块是8KB,那么这个块上最多放7个聚簇键
向聚簇中放数据之前,需要先对聚簇建立索引.
create index emp_dept_cluster_idx on cluster emp_dept_cluster;
加载的方式应彩用一一对应的关系.加载完主表之后再加载从表
什么情况下不能用索引聚簇表
1)如果预料到聚簇中的表会大量修改,索引聚簇表会对DML的性能产生负面影响.
2)非常不适合对单表的全表扫描,因为只能引起对其它表的全表扫描
3)频繁对表进行TRUNCATE和加载,因为聚簇中的表是不能TRUNCATE的
SQL> truncate table dept;
truncate table dept
               *
ERROR at line 1:
ORA-03292: Table to be truncated is part of a cluster
如果数据主要用来读,不怎么修改,并且逻辑上与聚簇连接想适合,最好使用索引聚簇表
oracle数据字典就是这样做的
SQL> set autotrace traceonly statistics
SQL> select a.deptno,b.ename from dept_02 a,emp_02 b where a.deptno=b.deptno and
a.deptno='30';
6 rows selected.
Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE
   1    0   MERGE JOIN
   2    1     INDEX (UNIQUE SCAN) OF 'dddd' (UNIQUE)
   3    1     FILTER
   4    3       TABLE ACCESS (FULL) OF 'EMP_02'
Statistics
----------------------------------------------------------
          0 recursive calls
          0 db block gets
          5 consistent gets
          0 physical reads
          0 red


相关文档:

C# 调用Oracle 存储过程返回数据集 实例

1. 在oracle 下创建表
     t_user(
        ID varchar(20),
        Name varchar(20)
       )
 2.  添加数据 
         &nb ......

Oracle 连接 复习

SQL> select * from ta;
        ID NAME
---------- --------------------
         1 gorey
         2 gorey2
SQL> select * from tb;
        I ......

Oracle 游标 Cursor 使用

create or replace procedure getok
as
cursor mycur is select ids,name from aaa where name not in (select names from ok);
vempno aaa.ids%type;
vename aaa.name%type;
begin
open mycur;
loop
fetch mycur into vempno,vename;
exit when mycur%notfound;
if mycur%found then
    insert ......

oracle删除表中所有的数据

示例一:delete from emp;
实例二:truncate table emp;
当使用delete删除时,虽然删除了表中的所有数据,但是没有释放表所占的空间,如果用户确定要删除表中所有数据,使用实例二语句速度更快。delete语句可以回退,但truncate语句操作不能回退,执行的时候要多加注意这一点。 ......

oracle使用子查询插入和修改数据

使用子查询插入数据:
示例一:insert into employee (empno,ename,sal,deptno)
           select empno,ename,sal,deptno from emp
          where deptno=20;
示例二:insert /*+APPEND*/ into employee (empno,e ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号