Re: create table with table constraints - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: create table with table constraints
Date
Msg-id 20051215224915.GA46776@winnie.fuhr.org
Whole thread Raw
In response to Re: create table with table constraints  (Jim Beckstrom <jrbeckstrom@sbcglobal.net>)
List pgsql-novice
On Thu, Dec 15, 2005 at 02:21:29PM -0800, Jim Beckstrom wrote:
> I looked at CREATE TABLE for both 8.0 and 7.2, they seem to be the
> same.  I reverted to CREATE INDEX [UNIQUE]..., and that still works.

[snip 89-line example]

It's easier to find problems if you reduce them to the smallest
possible test case; the example you posted was bigger than it needed
to be.  Anyway, here's what's wrong:

% psql -f test.sql
psql:test.sql:89: ERROR:  syntax error at or near "(" at character 6692
psql:test.sql:89: LINE 86:              CONSTRAINT clientru  (casenbr),
psql:test.sql:89:                                            ^

The offending lines are:

>              CONSTRAINT clientru  (casenbr),
>              CONSTRAINT assgnther  (assgnther, casenbr, th_ack_dat),
>              CONSTRAINT firstname  (firstname),
>              CONSTRAINT program  (program1, intakedate, ssnbr))");

You're trying to define several constraints but you've neglected
to declare what kind of constraints they are.  If you want them to
be UNIQUE constraints then do what you did on the lines immediately
preceding:

>              CONSTRAINT intakedt UNIQUE (intakedate, casenbr),
>              CONSTRAINT client_case UNIQUE (intakedate, casenbr),
>              CONSTRAINT clientss UNIQUE (intakedate, casenbr),
>              CONSTRAINT clientname UNIQUE (intakedate, casenbr),

--
Michael Fuhr

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: create table with table constraints
Next
From: Mike Shen
Date:
Subject: how do I import pqsl 7.1 database into 8.0