CONSTRAINT name With Domain As Check

Started by Rich Shepardalmost 19 years ago3 messagesgeneral
Jump to latest
#1Rich Shepard
rshepard@appl-ecosys.com

I define a table, Permits, that includes a column for type.

Permit_Type is a domain with permissible names:

CREATE DOMAIN Permit_Type
as TEXT
CHECK (value in ('Environmental', 'Health', 'Safety', 'Occupancy'));

Can I name that domain check within the Permits table as follows?

CREATE TABLE Permits (
...
type Permit_Type
CONSTRAINT invalid_permit_type
...
);

If not, does the constraint name belong in the domain definition?

Rich

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerator(TM)
<http://www.appl-ecosys.com&gt; Voice: 503-667-4517 Fax: 503-667-8863

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rich Shepard (#1)
Re: CONSTRAINT name With Domain As Check

Rich Shepard <rshepard@appl-ecosys.com> writes:

I define a table, Permits, that includes a column for type.
Permit_Type is a domain with permissible names:

CREATE DOMAIN Permit_Type
as TEXT
CHECK (value in ('Environmental', 'Health', 'Safety', 'Occupancy'));

Can I name that domain check within the Permits table as follows?

CREATE TABLE Permits (
...
type Permit_Type
CONSTRAINT invalid_permit_type
...
);

Um, what are you trying to do that's different from declaring a column
of the table as being of type Permit_Type?

regards, tom lane

#3Rich Shepard
rshepard@appl-ecosys.com
In reply to: Tom Lane (#2)
Re: CONSTRAINT name With Domain As Check

On Sun, 29 Apr 2007, Tom Lane wrote:

Um, what are you trying to do that's different from declaring a column of
the table as being of type Permit_Type?

Tom,

Nothing. After further consideration I decided that the domain was
unnecessary and the table column with a CHECK() constraint the more
appropriate approach.

Thanks,

Rich

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerator(TM)
<http://www.appl-ecosys.com&gt; Voice: 503-667-4517 Fax: 503-667-8863