The syntax about CREATE DOMAIN

Started by Gary WANabout 22 years ago3 messagesbugs
Jump to latest
#1Gary WAN
wan_on@hotmail.com

Dear Sir,
I would like to tell you that the SQL about "Create Domain" is still
cannot involve constraints other than NULL | NOT NULL in Postgresql 7.4.1.

For instances, when I type the following sentences, it shows error
message:

Create Domain GenderDomain CHAR(1) Constraint g Check Value in ('M','F');

Error: syntax error at or new "VALUE" at character ...

How can I obtain the correct syntax about domain in postgresql?

Regards,
Gary

_________________________________________________________________
Get 10Mb extra storage for MSN Hotmail. Subscribe Now!
http://join.msn.com/?pgmarket=en-hk

#2Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Gary WAN (#1)
Re: The syntax about CREATE DOMAIN

On Tue, 24 Feb 2004, Gary WAN wrote:

Dear Sir,
I would like to tell you that the SQL about "Create Domain" is still
cannot involve constraints other than NULL | NOT NULL in Postgresql 7.4.1.

For instances, when I type the following sentences, it shows error
message:

Create Domain GenderDomain CHAR(1) Constraint g Check Value in ('M','F');

Error: syntax error at or new "VALUE" at character ...

How can I obtain the correct syntax about domain in postgresql?

sszabo=# \h create domain
Command: CREATE DOMAIN
Description: define a new domain
Syntax:
CREATE DOMAIN name [AS] data_type
[ DEFAULT expression ]
[ constraint [ ... ] ]

where constraint is:

[ CONSTRAINT constraint_name ]
{ NOT NULL | NULL | CHECK (expression) }

Note the parentheses around the check expression.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Gary WAN (#1)
Re: The syntax about CREATE DOMAIN

"Gary WAN" <wan_on@hotmail.com> writes:

Create Domain GenderDomain CHAR(1) Constraint g Check Value in ('M','F');

You need parentheses around the check expression. AFAICS this is per
spec.

regards, tom lane