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
相关文档:
SQL的优化应该从
5
个方面进行调整:
1.去掉不必要的大型表的全表扫描
2.缓存小型表的全表扫描
3.检验优化索引的使用
4.检验优化的连接技术
5.尽可能减少执行计划的
Cost
SQL语句:
是对数据库(
数据
)
进行操作的惟一途径;
消耗了70%~90%
的数据库资源;独立于程序设计逻辑,相对于对程序源代码的优化, ......
select custid,carid,Cunote,INVNO,BUYPLAN
from ( select custid,carid,Cunote,INVNO,BUYPLAN,
row_number() over(partition by custid,carid order by Feedbackid desc) rn
from pvE3S.T_VCTM_CUSTOMER_FEEDBACK) t1 where rn=1
按Feedbackid 排序,rn是前N行 ......
自己整理了下Oracle的数据库备份方案,用过冷备份。其他没有测试过
一、 导出/导入(Export/Import)
利用Export可将数据从数据库
中提取出来,利用Import则可将提取出来的数据送回到Oracle
数据库中去。
1、 简单导出数据(Export)和导入数据(Import):
Oracle支持三种方式类型的输出:
(1)、表方式(T方 ......
t表中将近有1100万数据,很多时候,我们要进行字符串匹配,在SQL语句中,我们通常使用like来达到我们搜索的目标。但经过实际测试发现,like的效率与instr函数差别相当大。下面是一些测试结果:
SQL> set timing on
SQL> select count(*) from t where instr(title,’手册’)>0;
COUNT(*)
—&md ......
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 ......