Thread: Foreign Keys in PostGreSQL

Foreign Keys in PostGreSQL

From
"vijayendra mohan agrawal"
Date:
Dear all,

How to define FOREIGN KEY in a table ???

Thank You,
Best Regards,
Vijay

************************************************************
Vijayendra Mohan Agrawal
Wipro Technologies
26, Hosur Main Road, Bommanhalli,
Bangalore-560068, India
Tel: 91-80-5722296 Extn:3076
Fax: 91-80-5722696
E-mail : Vijayendra.Agrawal@wipro.com
**************************************************************

Re: Foreign Keys in PostGreSQL

From
Karel Zak
Date:
On Wed, 6 Sep 2000, vijayendra mohan agrawal wrote:

> Dear all,
>
> How to define FOREIGN KEY in a table ???

Found you some problem in great PostgreSQL documentation?

                    Karel

CREATE [ TEMPORARY | TEMP ] TABLE table (
    column type
    [ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT value ]
    [column_constraint_clause | PRIMARY KEY } [ ... ] ]
    [, ... ]
    [, PRIMARY KEY ( column [, ...] ) ]
    [, CHECK ( condition ) ]
    [, table_constraint_clause ]
    ) [ INHERITS ( inherited_table [, ...] ) ]

Column CONSTRAINT Clause

[ CONSTRAINT name ] { PRIMARY KEY |  UNIQUE } ( column [, ...] )
[ CONSTRAINT name ] CHECK ( constraint )
[ CONSTRAINT name ] FOREIGN KEY ( column [, ...] )
                     REFERENCES reftable
                      (refcolumn [, ...] )
                      [ MATCH matchtype ]
                      [ ON DELETE action ]
                      [ ON UPDATE action ]
                      [ [ NOT ] DEFERRABLE ]
                      [ INITIALLY checktime ]

 .......etc. ....etc.