Oracle 的视图与索引
有表A(字段A1,A2)和表B(字段B1,B2).
字段A2,B2上都有索引.
A,B 表联查
sql1 这个sql 非常快 2秒的样子
select * from A,B where A.A1=B.B1(+) and A2='值1'
sql2 这个sql 慢到让人无法忍受
select * from A,B where A.A1=B.B1(+) and B2='值1'
外联以后 表B上的索引不起作用了.
如果换成内联 速度很快.
select * from A,B where A.A1=B.B1 and B2='值1'
1.物化视图
普通视图不可以建索引。物化视图可以建索引。
CREATE MATERIALIZED VIEW m_tb REFRESH WITH ROWID as select * from tb;
create index idx_tb on m_tb(col1);
2.用hint语句强制指定优化器类型
select /*+index(A,idx_a1) index(B,idx_b1)*/* from A,B where A.A1=B.B1(+) and B1='值1'
2010-02-16 16:04:51 BY TZC
相关文档:
Hey all,
Since there seems to be a fair bit of disinformation, and utter nonsense,
floating around since my talk at the Black Hat Federal security conference
the other day, I have decided to publish the following papers.
http://www.databasesecurity.com/HackingAurora.pdf
http://www.databasesec ......
一、 内存结构
共享池:分为库高速缓存和字典高速缓冲区
库高速缓存,用于存储经过语法分析并且正确的SQL语句,并随时准备执行。
字典高速缓冲区,存储登陆到ORACLE的用户名,及这些用户有哪些数据库对象以及这些数据库对象的位置。
数据缓 ......
ORACLE 数据库对象
——索引
q 索引是与表相关的一个可选结构
q 用以提高 SQL 语句执行的性能
q 减少磁盘I/O
q 使用 CREATE INDEX 语句创建索引
q &n ......
过程、函数
create or replace procedure p1
is
empname emp.ename%type;
begin
select ename into empname from emp where empno=7788;
dbms_output.put_line(empname);
end;
SQL> ed
SQL> /
Procedure created
SQL> exec p1;
......
ORACLE数据库对象
——同义词、序列、视图
同义词:同义词是现有对象的别名
简化SQL语句
隐藏对象的名称和所有者
提供对对象的公共访问
同义词分为私有同义词和公有同义词
私有同义词只能在其模式内访问,且不能与当前模式的对象同名。
公有同义词可被所有的数据库用户访问。
以 SYS 用 ......