Skip site navigation (1) Skip section navigation (2)

Re: [GENERAL] CREATE TABLE ... CONSTRAINT

From: Dario Besseghini <besseghi(at)Di(dot)Unipi(dot)IT>
To: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] CREATE TABLE ... CONSTRAINT
Date: 1998-08-18 14:12:39
Message-ID: 199808181412.QAA03534@thorin.di.unipi.it (view raw or flat)
Thread:
Lists: pgsql-general
> 
> Ciao Dario,
> 
> Seems that your syntax (CREATE TABLE test (number int4) CONSTRAINT
> test_number CHECK number > 3;)
> isn't SQL standard.
> 
> -----------------------
> There are two kinds of Integrity CONSTRAINTs;
>     - the Column constraint:
>       CREATE TABLE test ( number int check ( number > 3 ) );
> and
>     - the Table constraint:
>       CREATE TABLE test ( number int4 CONSTRAINT test_number CHECK (number > 3));
> 
> This one has the right syntax and it works.
> 
> Best regards,
>   Jose'                            mailto:sferac(at)bo(dot)nettuno(dot)it
> 


Ciao Jose'.

  I know that the two forms you mention do work. pg_dump, however, not
I, uses the third form, which doesn't work.

$ pg_dump -t test testdata
\connect - besseghi
CREATE TABLE test (number int4) CONSTRAINT test_number CHECK number > 3;
COPY test FROM stdin;
\.

  The point of my post was  that I think  the postgresql parser should
accept pg_dump's output. Both solutions are legitimate: either pg_dump
or the  parser might be changed. In  the former  case, the docs should
also be  changed,  because both  `\h create table'  in  psql  and `man
create_table' put CONSTRAINT outside the parentheses.

Bye,
Dario


In response to

pgsql-general by date

Next:From: Rostislav MatlDate: 1998-08-18 14:21:39
Subject: S-Designor definition file for PostgreSQL, alpha release
Previous:From: G.Elangovan Date: 1998-08-18 14:02:09
Subject: Re: [GENERAL] Database Connect Permission

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group