Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
21
Добавлен:
05.06.2015
Размер:
385 Кб
Скачать

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