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
相关文档:
在一般Select语句中我们通过Order by ...Asc/Desc来进行排序。但是这种排序方式在输出时,不包含排序后的序号信息。
现在介绍一下Oracle中可以用于排序输出的方法。
1. RANK ( ) OVER ( [query_partition_clause] order_by_clause )
RANK ( ) OVER ( [query_p ......
Oracl 数据库也没有个半段表是否存在,存在则删除的语句,经过研究和改写他人的方法先隆重推出绝对能用性的Oracle判断表是否存在,存在则删除方法,在Oracle10g上试验通过。
方法
CREATE OR REPLACE FUNCTION PROC_NAME(T_NAME IN VARCHAR2) RETURN NUMBER IS
V_CNT number;
V_SQL VARCHAR2(100);
......
根据用户导出语句:
1.数据库导出
exp system/jade@JADE_166.111.134.26 file=d:\jade.dmp statistics=none
说明:
syste是用户名
jade是密码
JADE_166.111.134.26是SID标示
file=d:\jade.dmp 是导出文件的路径及文件名
2.数据库导入
imp system/jade@JADE_166.111.134.26 file=d:\jade.dmp fromuser=syst ......
使用子查询插入数据:
示例一:insert into employee (empno,ename,sal,deptno)
select empno,ename,sal,deptno from emp
where deptno=20;
示例二:insert /*+APPEND*/ into employee (empno,e ......
oracle补丁下载地址
DB 2009-10-28 18:00 阅读56 评论0
字号: 大大 中中 小小
Oracle 11g 11.1.0.7
ftp://updates.oracle.com/6890831/p6890831_111070_AIX5L_1of2.zip
ftp://updates.oracle.com/6890831/p6890831_111070_AIX5L_2of2.zip
ftp://upda ......