Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / 11-DDL-constraints.ppt
Скачиваний:
15
Добавлен:
12.05.2015
Размер:
155.14 Кб
Скачать

Viewingi i Constraintsi

Query the USER_CONSTRAINTS table to view all constraint definitions and names.

SQL>

SELECT

constraint_name, constraint_type,

2

 

search_condition

3

FROM

user_constraints

4WHERE table_name = 'EMP';

 

 

 

 

 

CONSTRAINT_NAME

C SEARCH_CONDITION

 

 

------------------------

- -------------------------

 

 

SYS_C00674

C EMPNO IS NOT NULL

 

 

SYS_C00675

C DEPTNO IS NOT NULL

 

 

EMP_EMPNO_PK

P

 

 

...

 

 

 

 

 

 

 

 

 

 

11-22

Viewingi i the Columnsl Associatedi withi Constraintsi

View the columns associated with the constraint names in the USER_CONS_COLUMNS view

 

 

 

 

 

 

 

SQL>

SELECT

constraint_name, column_name

 

 

2

FROM

user_cons_columns

 

 

3

WHERE

table_name = 'EMP';

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CONSTRAINT_NAME

COLUMN_NAME

 

 

-------------------------

----------------------

 

 

EMP_DEPTNO_FK

 

DEPTNO

 

 

EMP_EMPNO_PK

 

EMPNO

 

 

EMP_MGR_FK

 

MGR

 

 

SYS_C00674

 

EMPNO

 

 

SYS_C00675

 

DEPTNO

 

 

 

 

 

 

 

11-23

Summary

Creater te thet followingf ll i typest off constraints:tr i t :

NOT NULL

UNIQUEI key

PRIMARYI KEY

FOREIGNI KEY

CHECK

Queryry thet USER_CONSTRAINTSI tablet le toto viewi allll constrainttr i t definitionsfi iti and names..

11-24

Practicei Overviewi

Adding constraints to existing tables

Adding constraints to existing tables

Adding additional columns to a table

Adding additional columns to a table

Displaying information in data dictionary views

Displaying information in data dictionary views

11-25

Соседние файлы в папке 1 - Oracle