简体   繁体   English

如何更改表以在现有列上添加约束

[英]how to alter table to add the constraint on a existing column

Alter EMP_BACKUP table to add the following constraint.更改 EMP_BACKUP 表以添加以下约束。 Job column should take any of the following values only (CLERK, SALESMAN, MANAGER, ANALYST, PRESIDENT) Job 列应仅采用以下任何值(CLERK、SALESMAN、MANAGER、ANALYST、PRESIDENT)

how to add constraint on a job column which take values (CLERK, SALESMAN, MANAGER, ANALYST, PRESIDENT) only.如何在仅采用值(CLERK、SALESMAN、MANAGER、ANALYST、PRESIDENT)的作业列上添加约束。

alter table EMP_BACKUP add job 

The syntax is in the documentation :语法在文档中:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM