Postgresql constraint

前端 未结 4 1053
终归单人心
终归单人心 2021-02-06 21:23

I cannot seem to get this right, I am trying to modify a field to be a foreign key, with cascading delete... what am i doing wrong?

ALTER TABLE my_table 
ADD CON         


        
4条回答
  •  误落风尘
    2021-02-06 21:38

    It would help if you posted the error message. But I think you are just missing the parenthesis:

    ALTER TABLE my_table 
    ADD CONSTRAINT my_fk 
    FOREIGN KEY (my_field) 
    REFERENCES my_foreign_table 
    ON DELETE CASCADE;
    

提交回复
热议问题