ocp-047-112 conncet by prior
来源:互联网 发布:易售乐软件 编辑:程序博客网 时间:2024/05/30 07:13
Evaluate the following SQL st atement s:
S tatement 1:
SELECT employee_id, last_name, job_id, manager_id
FROM employees
ST ART WITH employee_id = 101
CONNECT BY PRIOR employee_id = manager_id AND manager_id != 108 ;
S tatement 2:
SELECT employee_id, last_name, job_id, manager_id
FROM employees
WHERE manager_id != 108
ST ART WITH employee_id = 101
CONNECT BY PRIOR employee_id = manager_id;
Which two st atements are true regarding the above SQL statements? (Choose two.)
A. S tatement 2 would not execute because the WHERE clause condition is not allowed in a statement that
has the ST ART W ITH clause.
B. The output for st atement 1 would display the employee with MANAGER_ID 108 and all the employees
below him or her in the hierarchy .
C. The output of st atement 1 would neither display the employee with MANAGER_ID 108 nor any
employee below him or her in the hierarchy .
D. The output for statement 2 would not display the employee with MANAGER_ID 108 but it would disp lay
all the employees below him or her in the hierarchy .
Answer: CD
标准语法:
select col_name...
from table_name
where 条件
start with 条件
connect by prior条件
where子句必须出现在start with和connect by子句之前,否则报错
实验:
SQL> select * from t3;ID NAME SA MGR_ID---------- ---------- ---------- ----------1 刘备 10002 诸葛亮 800 13 马超 900 24 士兵甲 500 3SQL> select * from t3 start with id=2 connect by prior id=mgr_id;ID NAME SA MGR_ID---------- ---------- ---------- ----------2 诸葛亮 800 13 马超 900 24 士兵甲 500 3SQL> select * from t3 start with id=2 connect by prior mgr_id=id;ID NAME SA MGR_ID---------- ---------- ---------- ----------2 诸葛亮 800 11 刘备 1000SQL> select * from t3 start with mgr_id=2 connect by prior id=mgr_id;ID NAME SA MGR_ID---------- ---------- ---------- ----------3 马超 900 24 士兵甲 500 3SQL> select * from t3 start with mgr_id=2 connect by prior mgr_id=id;ID NAME SA MGR_ID---------- ---------- ---------- ----------3 马超 900 22 诸葛亮 800 11 刘备 1000
由以上实验得出结论:start with 只是选择了起点,id=mgr_id是自起点向下按照start whit 的字段遍历,mgr_id=id就是自起点向上按照start whit 的字段遍历。
- ocp-047-112 conncet by prior
- Oracle之conncet by 之练习篇 sys_connect_by_path
- Oracle之递归函数查询start-with-conncet-by
- connect by prior
- connect by prior
- connect by prior
- connect by prior
- connect by prior
- connect by prior
- connect by prior start with
- connect by prior start with
- Oracle Connect By Prior用法
- CONNECT BY PRIOR... START WITH
- connect by prior start with
- Start With......Connect by prior..
- start with connect by prior
- connect by prior...start with...
- start with ... connect by prior ...
- [leetcode]Longest Consecutive Sequence
- 带进度条的输入流
- 如何动态加载.unity3d资源文件
- 【OUI-10151】安装oracle cluster时 的报错
- C语言/C++中怎样产生随机数
- ocp-047-112 conncet by prior
- 面试笔试之itoa函数
- 四叉树空间索引原理及其实现
- 高质量C++/C编程指南 -- 第1章 文件结构
- 搭建cocos2d-x的android环境(学习笔记)
- 第一篇博客
- Java中的Enum的使用
- 【4招搞定注册表键值快速定位】
- 黑马程序员--面向对象(多态)