Created
December 19, 2024 01:38
-
-
Save yahonda/7e61f3f71681cfa03111fed55714b0b4 to your computer and use it in GitHub Desktop.
not valid
This file contains 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
test=# CREATE TABLE "posts" ("id" bigserial primary key, "title" character varying); | |
CREATE TABLE | |
test=# ALTER TABLE "posts" ADD CONSTRAINT posts_const CHECK (char_length(title) >= 5) NOT VALID; | |
ALTER TABLE | |
test=# CREATE TABLE "comments" ("id" bigserial primary key, "body" text, CONSTRAINT comments_const CHECK (char_length(body) >= 5) NOT VALID); | |
CREATE TABLE | |
test=# SELECT conname, convalidated FROM pg_constraint WHERE contype = 'c' | |
and conname in('posts_const','comments_const'); | |
conname | convalidated | |
----------------+-------------- | |
posts_const | f | |
comments_const | t | |
(2 rows) | |
test=# \d posts | |
Table "public.posts" | |
Column | Type | Collation | Nullable | Default | |
--------+-------------------+-----------+----------+----------------------------------- | |
id | bigint | | not null | nextval('posts_id_seq'::regclass) | |
title | character varying | | | | |
Indexes: | |
"posts_pkey" PRIMARY KEY, btree (id) | |
Check constraints: | |
"posts_const" CHECK (char_length(title::text) >= 5) NOT VALID | |
test=# \d comments | |
Table "public.comments" | |
Column | Type | Collation | Nullable | Default | |
--------+--------+-----------+----------+-------------------------------------- | |
id | bigint | | not null | nextval('comments_id_seq'::regclass) | |
body | text | | | | |
Indexes: | |
"comments_pkey" PRIMARY KEY, btree (id) | |
Check constraints: | |
"comments_const" CHECK (char_length(body) >= 5) | |
test=# select version(); | |
version | |
-------------------------------------------------------------------- | |
PostgreSQL 18devel on x86_64-linux, compiled by gcc-11.5.0, 64-bit | |
(1 row) | |
test=# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment