From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: him@nathanmlong.com
Subject: Show how to incrementally make a column NOT NULL
Date: Mon, 09 Oct 2023 18:34:38 +0000
Message-ID: <169687647875.650.18286290464025494214@wrigleys.postgresql.org> (raw)
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/16/sql-altertable.html
Description:
In the examples on
https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-NOTES,
I suggest adding the following.
To make an existing column `NOT NULL` with the least impact on other work:
```
-- prevent new NULL values
ALTER TABLE distributors ADD CONSTRAINT street_not_null CHECK (street IS NOT
NULL) NOT VALID;
-- optionally, pause here to fix existing NULL values
ALTER TABLE distributors VALIDATE CONSTRAINT street_not_null;
ALTER TABLE distributors ALTER COLUMN street SET NOT NULL;
-- check constraint no longer needed
ALTER TABLE distributors DROP CONSTRAINT street_not_null;
```
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: noreply@postgresql.org, pgsql-docs@lists.postgresql.org, him@nathanmlong.com
Subject: Re: Show how to incrementally make a column NOT NULL
In-Reply-To: <169687647875.650.18286290464025494214@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox