foreign keys - Auto add data to postgresql database -




i have postgresql database 3 tables. 1 of these store id other 2 tables foreign keys. using table make connection between other 2 tables. problem don't know how add id's data table other.

you can use postgresql triggers automatic insertion of data here little example of how

   create or replace function insert_id() returns trigger $example_table$    begin       insert table_name(id) values (new.id);       return new;    end; $example_table$ language plpgsql; 

now can call same procedure using triggers functionality in postgres

create trigger example_trigger after insert on table_name each row execute procedure insert_id(); 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -