From: | "Thomas LeBlanc" <thomasatiem(at)hotmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Foreign Keys |
Date: | 2003-11-21 20:35:54 |
Message-ID: | Law9-F94iZWw8gRzpPW00003b12@hotmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I am able to enter a null in a foreign key field in one table(table2)
without the foreign key relationship (table1.t1_id) validating the value.
Why is this?
Below are 2 table's scripts:
create table table1 (
t1_id VARCHAR(32) not null,
t1_desc VARCHAR(32) null,
constraint table1_pkey primary key (t1_id) ) ;
create table table2 (
t2_id VARCHAR(32) not null,
t1_id VARCHAR(32) null,
t2_desc VARCHAR(32) null,
constraint table2_pkey primary key (t2_id) ) ;
create index table2_t1_id
on table2 ( t1_id ) ;
alter table table2
add constraint table1_table2_t1_id_FK1
foreign key ( t1_id )
references table1 ( t1_id )
ON DELETE RESTRICT ON UPDATE CASCADE ;
_________________________________________________________________
Is there a gadget-lover on your gift list? MSN Shopping has lined up some
good bets! http://shopping.msn.com
From | Date | Subject | |
---|---|---|---|
Next Message | Carmen Gloria Sepulveda Dedes | 2003-11-21 20:37:53 | Re: Execute vacuum |
Previous Message | Bruno Wolff III | 2003-11-21 20:27:11 | Re: linking postgre to AD |