首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在postgresql中添加二选一非空约束

在postgresql中添加二选一非空约束
EN

Stack Overflow用户
提问于 2011-03-27 15:47:50
回答 1查看 16.1K关注 0票数 40

如果我在Postgresql中有一个表:

代码语言:javascript
复制
create table Education ( 
    id                  integer references Profiles(id),
    finished            YearValue not null,
    started             YearValue,
    qualification       text,
    schoolName          text,
    studiedAt           integer references Organizations(id),
    primary key (id)
);

我需要设置一个约束,这样schoolNamestudiedAt中的任何一个都不需要为空(其中一个必须包含信息)。

我该怎么做呢?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5447880

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档