Show how to incrementally make a column NOT NULL

Поиск
Список
Период
Сортировка
От PG Doc comments form
Тема Show how to incrementally make a column NOT NULL
Дата
Msg-id 169687647875.650.18286290464025494214@wrigleys.postgresql.org
обсуждение исходный текст
Список pgsql-docs
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;
```

В списке pgsql-docs по дате отправления:

Предыдущее
От: Brad White
Дата:
Сообщение: Re: ODBC options
Следующее
От: PG Doc comments form
Дата:
Сообщение: Setting up WAL archiving