Backend/db

제약조건(추가,삭제,(비)활성화,확인)

IT grow. 2018. 8. 17. 22:49
반응형

1.     제약조건 추가

ALTER TABLE table_name ADD

CONSTRAINT constraint_name constraint_type ( column );

# constraint_type : Primary key , Foreign key , Unique

2.     제약조건 삭제

ALTER TABLE table_name DROP

CONSTRAINT constraint_name[CASCADE];

3.     제약조건 ()활성화

ALTER TABLE table_name DISABLE/ENABLE

CONSTRAINT constraint_name[CASCADE];

4.     제약조건 확인

SELECT constraint_name, constraint_type

FROM user_constraints

WHERE table_name=’대문자로 테이블명’;


반응형