| From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
|---|---|
| To: | Stuart Campbell <stuart(dot)campbell(at)ridewithvia(dot)com>, pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Check whether a NOT NULL check constraint has been validated |
| Date: | 2025-12-01 03:07:47 |
| Message-ID: | 1b930bcc-16f4-4c97-93f8-a21d314ba373@aklaver.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 11/30/25 16:59, Stuart Campbell wrote:
> Hello,
>
> I have several NOT NULL check constraints in my schema that were
> originally added as NOT VALID. I would like to determine whether they
> have all since been validated, or not.
>
> I thought maybe pg_constraint.convalidated might help, but it seems like
> the version of Postgres I'm using (16) doesn't store not null
> constraints in that table. And even in later versions, maybe it doesn't
> hold the information I need.
>
> Is there another way to discover this?
1) Select count(*) from <table> where <col> IS NULL;
2) From here
https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-NOTES
ALTER TABLE <table> VALIDATE CONSTRAINT <constraint_name>;
As described:
". Once the constraint is in place, no new violations can be inserted,
and the existing problems can be corrected at leisure until VALIDATE
CONSTRAINT finally succeeds."
>
> This communication and any attachments may contain confidential
> information and are intended to be viewed only by the intended
> recipients. If you have received this message in error, please notify
> the sender immediately by replying to the original message and then
> delete all copies of the email from your systems.
>
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrian Klaver | 2025-12-01 03:23:12 | Re: Check whether a NOT NULL check constraint has been validated |
| Previous Message | Stuart Campbell | 2025-12-01 00:59:07 | Check whether a NOT NULL check constraint has been validated |