2009-08-31 7 views
0

Comment résoudre une contrainte FK? Avec déclencheur ou autre chose?Postgres: problème avec la contrainte FK

#IF "DELETE FROM human where name='a';", error due to the FK contraist. 

# If the error, I want in the order: 
# FIRSTLY. DELETE FROM address where name='a'; 
# SECONDLY. DELETE FROM human where name='a'; 


DROP TABLE human; 
DROP TABLE address; 

CREATE TABLE human(
     name varchar(300) PRIMARY KEY not null 

); 

CREATE TABLE address(
     name varchar(300) 
       references human.name 

); 

Répondre

3
CREATE TABLE address (
    name varchar(300) REFERENCES human (name) ON DELETE CASCADE 
); 

Est-ce ce que vous voulez?

Questions connexes