Re: REFERENCES troubles

From: JanWieck(at)t-online(dot)de (Jan Wieck)
To: PostgreSQL GENERAL <pgsql-general(at)postgresql(dot)org>
Subject: Re: REFERENCES troubles
Date: 2000-07-04 23:29:16
Message-ID: 200007042329.BAA04956@hot.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

planx plnetx wrote:
> I get this error when creating a database:
>
> CREATE TABLE workers(
> name varchar(30),
> firstname varchar(30),
> id_personal decimal(10)NOT NULL UNIQUE PRIMARY KEY,
> );
>
> CREATE TABLE payements(
> date_of date,
> owner REFERENCES workers(id_personal)
> );
>
>
> IT gimme error!!!
> why this isn't right?
> the postgres documentation seem say to do in this manner...

First thing incorrect is that you aren't creating a database,
you are creating tables inside of an existing one.

Second you just told us the statements that didn't work, but
not what the database is yelling, nor which version of
Postgres did so or the like.

Forgiven :-)

Third the comma after "PRIMARY KEY" in the "workers" table
declaration is a syntax error.

Forth you forgot to specify the data type of "owner" in the
"payments" table. If I add "decimal(10)" before "REFERENCES"
it works pretty good in 7.0.x.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tim Allen 2000-07-05 00:09:22 Re: [HACKERS] Revised Copyright: is this more palatable?
Previous Message swalker 2000-07-04 23:13:31 Re: Combining two SELECTs