- •Раздел 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.
16 Rows selected.
Q6_8
Удаление представлений
SQL> drop view emp_DEPTNO;
View dropped.
SQL> drop view d10emp;
View dropped.
6.3.Создание индексов
Q6_9
SQL> create index i_emp_sal_comm on EMP (sal,comm);
Index created.
SQL> create unique index i_DEPTNO_unq_dname on DEPTNO (dname);
Index created.
Q6_10
Запрос с использованием индекса i_DEPTNO_unq_dname
SQL> select * from DEPTNO
where dname like 'S%';
DEPTNO DNAME LOC
---------- -------------- -------------
30 SALES CHICAGO
Q6_11
Проверка структуры идекса
SQL> analyze index i_emp_sal_comm validate structure;
Index analyzed.
Q6_12
Удаление индексов
SQL> drop index i_emp_sal_comm;
Index dropped.
SQL> drop index i_DEPTNO_unq_dname;
Index dropped.
6.4. Кластеры Clusters
Q6_13
Создание кластера, содержащего таблицы EMP и DEPTNO
SQL> create cluster personnel (dep_number number(2))
storage (initial 100k next 50k pctincrease 10);
Cluster created.
SQL> create table DEPT_kl(
DEPTNO number(2) not null,
dname varchar2(13),
loc varchar2(9),
constraint DEPTNO_pk primary key (DEPTNO))
cluster personnel(DEPTNO);
Table created.
SQL> create table emp_kl (
empno number(4) not null,
ename varchar2(10),
job varchar2(9),
mgr number(4) constraint emp_self_key references emp_kl(empno),
hiredate date,
sal number(7,2),
comm number(7,2),
DEPTNO number(2) not null,
constraint emp_fk foreign key (DEPTNO) references DEPT_kl(DEPTNO),
constraint emp_pk primary key (empno))
cluster personnel (DEPTNO);
Table created.
Q6_14
Создание индекса кластера
SQL> create index idx_personnel on cluster personnel;
Index created.
scott@8i> insert into dept_kl
select * from dept;
4 rows created.
scott@8i> insert into emp_kl
select * from emp;
14 rows created.
Q6_15
Удаление кластера, всех таблиц, принадлежащих кластеру и всех ограничений целостности, не принадлежащих ему
SQL> drop cluster personnel
including tables cascade constraints;
Cluster dropped.
6.5. Синонимы SYNONYMS
Q6_16
Создание синонима к таблице COMM
SQL> create synonym commission for comm;
Synonym created.
SQL> select * from commission;
EMPNO COMM
--------- ---------
7499 1100
7654 500
7844 500
7844 1500
Q6_17
Удаление синонима
SQL> drop synonym commission;
Synonym dropped.
6.6. Создание снимка и выборка данных из него через представление
Q6_18
SQL> create snapshot snap_DEPTNO as
select * from DEPT;
Snapshot created.
SQL> create view DEPTNO as
select * from snap_DEPTNO
with read only;
View created.
SQL> select * from DEPTNO;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
