- •Раздел 1 Утилита sql*Plus, простые запросы выборки столбцов и строк
- •7839 King president 17-nov-81 5000 10
- •7900 James 950
- •7 Rows selected.
- •7 Rows selected.
- •14 Rows selected.
- •14 Rows selected.
- •14 Rows selected.
- •9 Rows selected.
- •14 Rows selected.
- •14 Rows selected.
- •14 Rows selected.
- •6 Rows selected.
- •14 Rows selected.
- •14 Rows selected.
- •7369 Smith 800
- •Функции Oracle sql
- •9 Rows selected.
- •Раздел 3 Выборка данных из нескольких таблиц
- •20 Smith 800
- •30 James 950
- •10 Miller 1300
- •6 Rows selected.
- •6 Rows selected.
- •6 Rows selected.
- •8 Rows selected.
- •8 Rows selected.
- •14 Rows selected.
- •9 Rows selected.
- •9 Rows selected.
- •14 Rows selected.
- •14 Rows selected.
- •14 Rows selected.
- •6 Rows selected.
- •15 Rows selected.
- •14 Rows selected.
- •14 Rows selected.
- •14 Rows selected.
- •7 Rows selected.
- •Раздел 4 Другие команды языка манипулирования данными dмl и обработка транзакций
- •7902 Ford analyst 7566 03-dec-81 3000 20
- •7788 Scott analyst 7566 09-dec-82 3000 20
- •Раздел 5 Создание и изменение таблиц средствами ddl
- •Раздел 6 Другие объекты базы данных
- •7934 Miller 10
- •16 Rows selected.
14 Rows selected.
Q3_27
JONES и его подчиненные
SQL> select lpad(' ',(level-1)*3)||level||' '||ename as tree,
EMPNO,job,mgr from EMP
connect by prior EMPNO=mgr
start with ename='JONES';
TREE EMPNO JOB MGR
---------------------------------------- --------- --------- ---------
1 JONES 7566 MANAGER 7839
2 FORD 7902 ANALYST 7566
3 SMITH 7369 CLERK 7902
2 SCOTT 7788 ANALYST 7566
3 ADAMS 7876 CLERK 7788
Q3_28
SMITH и его начальники
SQL> select lpad(' ',(level-1)*3)||level||' '||ename as tree,
EMPNO,job,mgr from EMP
connect by EMPNO = prior mgr
start with ename='SMITH';
TREE EMPNO JOB MGR
---------------------------------------- --------- --------- ---------
1 SMITH 7369 CLERK 7902
2 FORD 7902 ANALYST 7566
3 JONES 7566 MANAGER 7839
4 KING 7839 PRESIDENT
Q3_29
Исключение вершины SCOTT и ветви BLAKE
SQL> select lpad(' ',(level-1)*3)||level||' '||ename as tree,
EMPNO,job,mgr
from EMP
where ename <> 'SCOTT'
connect by prior EMPNO = mgr and ename <> 'BLAKE'
start with sal=5000;
TREE EMPNO JOB MGR
---------------------------------------- --------- --------- ---------
1 KING 7839 PRESIDENT
2 CLARK 7782 MANAGER 7839
3 MILLER 7934 CLERK 7782
2 JONES 7566 MANAGER 7839
3 FORD 7902 ANALYST 7566
4 SMITH 7369 CLERK 7902
4 ADAMS 7876 CLERK 7788
7 Rows selected.
Q3_30
Упорядочивание с помощью ORDER BY
SQL> select lpad(' ',(level-1)*3)||level||' '||ename as tree,
EMPNO,job,mgr
from EMP
connect by prior EMPNO = mgr
start with ename='JONES'
order by tree;
TREE EMPNO JOB MGR
---------------------------------------- --------- --------- ---------
3 ADAMS 7876 CLERK 7788
3 SMITH 7369 CLERK 7902
2 FORD 7902 ANALYST 7566
2 SCOTT 7788 ANALYST 7566
1 JONES 7566 MANAGER 7839
