简单介绍Oracle驱动表

数据库 Oracle
这里介绍Oracle驱动表,实际上在CBO中,如果有统计数据(即对表与索引进行了分析),则优化器会自动根据cost值决定采用哪种连接类型,并选择合适的Oracle驱动表,这与where子句中各个限制条件的位置没有任何关系。

Oracle有很多值得学习的地方,这里我们主要介绍Oracle驱动表,包括介绍hints的用法等方面。CBO根据统计信息选择Oracle驱动表,假如没有统计信息,则在from 子句中从左到右的顺序选择Oracle驱动表。这与RBO选择的顺序正好相反。这是英文原文(CBO determines join order from costs derived from gathered statistics. If there are no stats then CBO chooses the driving order of tables from LEFT to RIGHT in the FROM clause. This is OPPOSITE to the RBO) 。

我还是没法证实这句话的正确性。不过经过验证:“如果用ordered 提示(此时肯定用CBO),则以from 子句中按从左到右的顺序选择Oracle驱动表”这句话是正确的。实际上在CBO中,如果有统计数据(即对表与索引进行了分析),则优化器会自动根据cost值决定采用哪种连接类型,并选择合适的Oracle驱动表,这与where子句中各个限制条件的位置没有任何关系。如果我们要改变优化器选择的连接类型或Oracle驱动表,则就需要使用 hints了,具体hints的用法在后面会给予介绍。

如果我创建的3个表:

  1. create table A(col1 number(4,0),col2 number(4,0), col4 char(30));  
  2. create table B(col1 number(4,0),col3 number(4,0), name_b char(30));  
  3. create table C(col2 number(4,0),col3 number(4,0), name_c char(30));  
  4. create index inx_col12A on a(col1,col2); 

执行查询:

  1. select A.col4  
  2. from B, A, C  
  3. where B.col3 = 10 
  4. and A.col1 = B.col1  
  5. and A.col2 = C.col2  
  6. and C.col3 = 5;  
  7. Execution Plan 

【编辑推荐】

  1. 讨论Oracle文档学习经验
  2. 如何了解Oracle生成执行计划
  3. 详细谈论Oracle表连接
  4. 分析Oracle索引扫描四大类
  5. 高手闲谈Oracle索引扫描
责任编辑:佚名 来源: 博客
相关推荐

2009-10-20 18:30:03

Oracle查找用户表

2010-10-29 10:22:21

Oracle表空间

2010-04-28 18:49:10

Oracle临时表

2010-04-29 13:53:42

Oracle临时表

2009-07-07 11:38:54

jsp oracle

2011-08-11 16:08:55

Oracle数据库ASHAWR

2011-07-28 17:45:59

UTL_INADDRoracle

2011-03-22 14:49:35

Oracle数据库重定义表

2009-06-17 17:59:01

介绍Spring

2011-02-24 14:40:47

Proftpd

2011-01-21 10:40:52

Sendmail

2011-02-23 13:28:12

2011-01-21 16:49:15

Zimbra

2011-04-01 09:39:17

zabbix

2011-03-29 09:14:37

2011-03-04 13:19:09

VSFTP介绍

2011-02-22 16:38:03

Konqueror

2011-01-21 18:08:22

Qmail

2011-08-12 12:59:33

Oracle数据库同义词

2020-08-07 07:58:24

Oracle框架数据库
点赞
收藏

51CTO技术栈公众号