Re: create table with table constraints

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Jim Beckstrom <jrbeckstrom(at)sbcglobal(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: create table with table constraints
Date: 2005-12-15 22:49:15
Message-ID: 20051215224915.GA46776@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Mike Shen 2005-12-15 23:04:30 how do I import pqsl 7.1 database into 8.0
Previous Message Tom Lane 2005-12-15 22:35:57 Re: create table with table constraints