- •Раздел 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.
7900 James 950
7369 SMITH 800
7876 ADAMS 1100
7934 MILLER 1300
Q1_4a
scott@NINE.KAF29.MEPHI.RU> Insert into dept (deptno, Dname, loc)
Values(&department_number,'&department_nmae','&locacion');
Enter value for department_number: 88
Enter value for department_nmae: home
Enter value for locacion: Kashirka
old 2: Values(&department_number,'&department_nmae','&locacion')
new 2: Values(88,'home','Kashirka')
Q1_4b
scott@NINE.KAF29.MEPHI.RU> select * from &&table_name;
Enter value for table_name: dept –здесь введено значение для table_name
old 1: select * from &&table_name
new 1: select * from dept
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
50 ttt fff
70 sss www
88 home Kashirka
7 Rows selected.
scott@NINE.KAF29.MEPHI.RU> select * from &&table_name; --здесь уже отсутствует
--приглашение для ввода значения table_name.
--Отсутствие такого приглашения обеспечивает двойная &
old 1: select * from &&table_name
new 1: select * from dept
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
50 ttt fff
70 sss www
88 home Kashirka
7 Rows selected.
--как изменить значение для «table_name»
Q1_4c
scott@NINE.KAF29.MEPHI.RU> def table_name –def – сокращение от definition
DEFINE TABLE_NAME = "dept" (CHAR)
scott@NINE.KAF29.MEPHI.RU> DEFINE TABLE_NAME = "SALGRADE" (CHAR)
scott@NINE.KAF29.MEPHI.RU> select * from &&table_name;
old 1: select * from &&table_name
new 1: select * from SALGRADE
GRADE LOSAL HISAL
---------- ---------- ----------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
1.3. Выборка столбцов
Q1_5
Выборка всех столбцов из таблицы
SQL> select EMP.* from EMP;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
--------- ---------- --------- --------- --------- --------- --------- ----------
7839 KING PRESIDENT 17-NOV-81 5000 10
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7900 JAMES CLERK 7698 03-DEC-81 950 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7369 SMITH CLERK 7902 17-DEC-80 800 20
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
Q1_6
Использование арифметических выражений
Зарплата за 12 месяцев
SQL> select DEPTNO,sal*12,comm from EMP;
DEPTNO SAL*12 COMM
---------- --------- ---------
10 60000
30 34200
10 29400
20 35700
30 15000 1400
30 19200 300
30 18000 0
30 11400
30 15000 500
20 36000
20 9600
20 36000
20 13200
10 15600
