Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some values under "account" and I need to have the same values under "invoice", so, I'm trying to find a way to symlink my tables, so every time one gets updated, the another have the new value too. I'm developing under OpenERP, I can't trow that update directly on code, I need to write the rule using PgAdmin or something like.

I need to junction symlink 2 tables under Postgres.

ACCOUNT                INVOICE  
|#1|cc          |@@@@@@|#1|cc                  |  
|#2|cash        |@@@@@@|#2|cash                |  
|#3|cash        |@@@@@@|#3|cash                |  
share|improve this question

From your example it seems like invoice can be replaced with a simple VIEW, which is similar to a "symlink" in nature:

SELECT id, account_payment_type FROM account;

All done.
Else you need to be more specific in your question. Start with providing the complete table definition for both tables and add more information what is covered in each ...

share|improve this answer
Ok, I'll try to use that view. Many thanks. Next time I'll try to provide more info about the tables and the system. – Tonon Jun 10 '13 at 18:28
Can I create a table from a view? – Tonon Jun 10 '13 at 19:44
Sure you can. But that would defeat it's purpose, wouldn't it? Since you seem to understand that metaphor: it's lake making a hard copy from a symlink in the file system. Except if you mean in the sense of a materialized view? There is a new feature for that in the upcoming version 9.3 btw. – Erwin Brandstetter Jun 10 '13 at 20:16

At a guess, if a simple view doesn't meet your needs for whatever reason, maybe you're looking for triggers?

Add an AFTER ... FOR EACH ROW trigger on each table that does the INSERT, UPDATE or DELETE on the other table. You'll want to write it in PL/PgSQL. For details, see the PostgreSQL documentation on triggers.

Otherwise, maybe you want an updatable view? You can achieve that with a DO INSTEAD view trigger. Again, see the Pg docs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.