Search code examples
sqloraclecheck-constraints

how to alter table to add the constraint on a existing column


Alter EMP_BACKUP table to add the following constraint. Job column should take any of the following values only (CLERK, SALESMAN, MANAGER, ANALYST, PRESIDENT)

how to add constraint on a job column which take values (CLERK, SALESMAN, MANAGER, ANALYST, PRESIDENT) only.

alter table EMP_BACKUP add job 

Solution

  • The syntax is in the documentation:

    alter table emp_backup
    add constraint chk_job check (job in ('CLERK', 'SALESMAN', 'MANAGER', 'ANALYST', 'PRESIDENT'));