
사용자가 허락한 데이터만 입력 또는 수정할 수 있게 하는 제약
alter table 테이블명
add constraint 제약조건명 check(컬럼명 조건);
alter table emp
add constraint emp_sal_ck check(sal between 0 and 9000);
-- 에러발생
-- ORA-02290: 체크 제약조건(C##SCOTT.EMP_SAL_CK)이 위배되었습니다
update emp
set sal = 9500
where ename='KING';
alter table emp
add constraint emp_deptno_ck check(deptno in (10,20,30));
-- 에러발생
-- ORA-02290: 체크 제약조건(C##SCOTT.EMP_DEPTNO_CK)이 위배되었습니다
update emp
set deptno = 50
where ename='KING';
alter table emp21
add constraint emp21_email_ck check( email like '%@%.%' );
alter table emp21
add constraint emp21_telecom_ck check(telecom in
('SKT', 'KT', 'LG', 'SKT알뜰', 'KT알뜰', 'LG알뜰') );
create table dept901
( deptno number(10),
dname varchar2(20),
loc varchar2(20),
constraint dept901_loc_ck check(loc in ('DALLAS', 'CHICAGO', 'BOSTON')));
alter table emp21
drop constraint emp21_email_ck;
alter table emp21
drop constraint emp21_telecom_ck;