public inbox for [email protected]
help / color / mirror / Atom feedRe: Check whether a NOT NULL check constraint has been validated
2+ messages / 1 participants
[nested] [flat]
* Re: Check whether a NOT NULL check constraint has been validated
@ 2025-12-01 03:07 Adrian Klaver <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Adrian Klaver @ 2025-12-01 03:07 UTC (permalink / raw)
To: Stuart Campbell <[email protected]>; 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
[email protected]
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Check whether a NOT NULL check constraint has been validated
@ 2025-12-01 03:23 Adrian Klaver <[email protected]>
parent: Adrian Klaver <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Adrian Klaver @ 2025-12-01 03:23 UTC (permalink / raw)
To: Stuart Campbell <[email protected]>; pgsql-general
On 11/30/25 19:07, Adrian Klaver wrote:
> 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."
Realized I was looking at current docs and I should be looking at your
version
From the 16 version of the docs:
"This form adds a new constraint to a table using the same constraint
syntax as CREATE TABLE, plus the option NOT VALID, which is currently
only allowed for foreign key and CHECK constraints."
Now I am not sure what you did.
Are you saying you used a CHECK constraint to check for NULL values?
If so then pg_constraint.convalidated would work.
If not are you sure you are on Postgres 16?
>
>>
>> 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
[email protected]
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-12-01 03:23 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-12-01 03:07 Re: Check whether a NOT NULL check constraint has been validated Adrian Klaver <[email protected]>
2025-12-01 03:23 ` Adrian Klaver <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox