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
相关文档:
SQL> select * from ta;
ID NAME
---------- --------------------
1 gorey
2 gorey2
SQL> select * from tb;
I ......
TO_DATE格式
Day:
dd number 12
dy abbreviated fri
day spelled out friday
ddspth spelled out, ordinal twelfth
Month:
mm number 03
mon abbreviated mar
month spelled out march
Year:
yy two digits 98  ......
Sample
表空间:IMPTEMP
表:Roles 、Users
通过PL/SQL导出的数据库脚本
-----------------------------------------------------
-- Export file for user IMPTEMP --
-- Created by Administ ......
一、建立链接服务器
有人喜欢调用系统过程来建立,但我个人对系统过程没有特别的学习 ,所以用的是界面设置,当然有兴趣也可以研究一下的,因为可以把SQL执行导出来。
USE [master]
GO
EXEC master.dbo.sp_addlinkedserver @server = N'TEST2', @srvproduct=N'ORCL', @provider=N ......