Re: Implementing standard SQL's DOMAIN constraint

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Implementing standard SQL's DOMAIN constraint
Дата
Msg-id CAKFQuwbdtPmDR52TBX1EENEbYV2w02GzB1K5z_1O-r2ukfo4Kg@mail.gmail.com
обсуждение исходный текст
Ответ на Implementing standard SQL's DOMAIN constraint  (Rich Shepard <rshepard@appl-ecosys.com>)
Ответы Re: Implementing standard SQL's DOMAIN constraint  (Rich Shepard <rshepard@appl-ecosys.com>)
Список pgsql-general
On Wednesday, January 2, 2019, Rich Shepard <rshepard@appl-ecosys.com> wrote:

CREATE DOMAIN state_code AS char(2)
DEFAULT '??'
CONSTRAINT valid_state_code
CHECK (value IN ('AL', 'AK', 'AZ', ...));

This applies to all tables each having a column named state_code.

There is no magic name logic involved.  A domain is just a type with inherent constraints that are user definable.  You make use of it like any other type.

Create table tbl (
column_name state_code not null

Values stored in column_name are now of type state_code and constrained to be one of the check constraint values.

David J.

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

Предыдущее
От: Rich Shepard
Дата:
Сообщение: Implementing standard SQL's DOMAIN constraint
Следующее
От: Rich Shepard
Дата:
Сообщение: Re: Implementing standard SQL's DOMAIN constraint