Re: Forein Key - Mailing list pgsql-general

From Frank Joerdens
Subject Re: Forein Key
Date
Msg-id 20010309185352.A22425@rakete.joerdens.de
Whole thread Raw
In response to Forein Key  ("Marcelo Pereira" <gandalf@sum.desktop.com.br>)
List pgsql-general
On Fri, Mar 09, 2001 at 03:43:55PM -0300, Marcelo Pereira wrote:
>
>    Hi,
>
>
>
>    I'm a new user and I would like to know if I can create my table using
>    forein key's.

Sure. Here's an example:

test=> CREATE TABLE statename     (    code CHAR(2) PRIMARY KEY,
test(>                     name CHAR(30)
test(>                 );
CREATE
test=> INSERT INTO statename VALUES ('AL', 'Alabama');
INSERT 18934 1

test=> CREATE TABLE customer     (
test(>                 customer_id INTEGER,
test(>                 name CHAR(30),
test(>                 telephone CHAR(20),
test(>                 street CHAR(40),
test(>                 city CHAR(25),
test(>                 state CHAR(2) REFERENCES statename,
test(>                 zipcode CHAR(10),
test(>                 country CHAR(20)
test(>                 );
CREATE

(from Bruce Momjian's excellent book on PostgreSQL)

Regards, Frank

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Postgresql.org website search
Next
From: Doug McNaught
Date:
Subject: Re: functions for triggers: passing parameters