Created
March 16, 2015 07:01
-
-
Save knmkr/f861d92bb6369016902c to your computer and use it in GitHub Desktop.
Not null check in combination: check (foo is not null) or (bar is not null).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS snp_info; | |
CREATE TABLE snp_info ( | |
snp_id varchar NOT NULL, | |
foo integer, | |
bar integer | |
CHECK (foo IS NOT NULL OR bar IS NOT NULL) | |
); | |
-- Success: | |
-- INSERT INTO snp_info VALUES ('rs10', 1, NULL); | |
-- INSERT INTO snp_info VALUES ('rs10', NULL, 1); | |
-- Fail: | |
-- INSERT INTO snp_info VALUES ('rs10', NULL, NULL); | |
-- INSERT INTO snp_info VALUES (NULL, NULL, NULL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment