1번, 2번
3번
4번
5번
6번
7번
8번
9번
10번, 11번, 12번
13번, 14번, 15번
16번, 17번
18번
19번, 20번, 21번, 22번, 23번
괄호안의 동의어로도 조회 가능
desc dictionary;
select *
from dictionary
where table_name = 'USER_USERS';
요구사항 수집 및 분석
-> 개념모델링(ERD)
-> 논리모델링(구체화된 ERD, 테이블 차트)
-> 물리모델링(create table----;)
➀ NOT NULL 제약조건
create table test1
(id number(10) constraint t1_id_nn not null,
name varchar2(30) constraint t1_name_nn not null,
job varchar2(20),
email varchar2(20),
phone varchar2(20) constraint t1_ph_nn not null,
start_date date);
➁ UNIQUE 제약조건
create table test2
(id number(10) constraint t2_id_nn not null constraint t2_id_uk unique,
name varchar2(30) constraint t2_name_nn not null,
job varchar2(20),
email varchar2(20),
phone varchar2(20) constraint t2_ph_nn not null constraint t2_ph_uk unique,
start_date date, constraint t2_email_uk unique(email));
➂ PRIMARY KEY 제약조건
create table test3
(id number(10) constraint t3_id_pk primary key,
name varchar2(30) constraint t3_name_nn not null,
job varchar2(20),
email varchar2(20),
phone varchar2(20) constraint t3_ph_nn not null constraint t3_ph_uk unique,
start_date date,
constraint t3_email_uk unique(email));
➃ FOREIGN KEY 제약조건
➄ CHECK 제약조건
테이블 레벨, 컬럼 레벨 제약조건 선언 방식이 같다
create table employees1
(employee_id number(6)
constraint emp1_employee_id primary key,
first_name varchar2(20),
last_name varchar2(25)
constraint emp1_last_name_nn not null,
email varchar2(25)
constraint emp1_email_nn not null
constraint emp1_email_uk unique,
phone_number varchar2(20),
hire_date date
constraint emp1_hire_date_nn not null,
job_id varchar2(10)
constraint emp1_job_nn not null,
salary number(8,2)
constraint emp1_salary_ck check(salary>0),
commission_pct number(2,2),
manager_id number(6)
constraint emp1_manager_fk references employees(employee_id),
department_id number(4)
constraint emp1_dept_fk references departments(department_id));
내 소유 테이블에 선언되어 있는 제약조건 정보 볼수 있는 테이블
desc user_constraints;
select constraint_name, constraint_type, search_condition, r_constraint_name
from user_constraints
where lower(table_name) = 'employees';
search_cons.sql
로 저장