| From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
|---|---|
| To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
| Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Implementing standard SQL's DOMAIN constraint |
| Date: | 2019-01-02 17:52:43 |
| Message-ID: | CAKFQuwb30m1-d35As74bFL8eWxg0oGN7YLW1443P-ZbTPG=-Wg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Wednesday, January 2, 2019, Rich Shepard <rshepard(at)appl-ecosys(dot)com>
wrote:
> On Wed, 2 Jan 2019, David G. Johnston wrote:
>
> 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,
>
> I'm not following you. I have two tables each with a column,
> state_code char(2) NOT NULL.
>
> Do you mean that I need to write the column constraint for each table? If
> not, I don't see from your response how to implement the multi-table
> constraint for this column.
>
>
That is a char(2) column for which ‘??’ is a valid value. The fact that it
is named state_code is immaterial; the domain that you created doesn’t get
used. There is no magic linking just by virtue of using the same name.
Change char(2) to state_code if you wish to apply the domain on the column.
David J.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Rich Shepard | 2019-01-02 17:58:41 | Re: Implementing standard SQL's DOMAIN constraint |
| Previous Message | Rich Shepard | 2019-01-02 17:47:42 | Re: Implementing standard SQL's DOMAIN constraint |