Rat*_*mar 5 postgresql postgresql-10
我是 postgres 新手
如何创建带有列名检查约束的表,比如污染,只需要在插入时接受“是”或“否”值。
对于其他值,它应该提示错误消息
我的表名称是车辆
小智 16
使用in条件。
create table vehicles
(
id integer primary key,
polluted text not null check (polluted in ('yes', 'no'))
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8331 次 |
| 最近记录: |