简体   繁体   中英

Oracle: keep a table up to date to another

We use Oracle database and now I face a problem.

We need to copy a subset of columns from table A to a new table B:

Table A
Name|Birth Date|Location|Office

Table B
Name|Location

And table A will change quite often (several times in a month). And it's managed by another team.

What is the best way to keep synchronized the table B from table A ?

Thank you very much.

Instead of a new table - think of a view or a materialized view .

View won't even occupy any space, it is just a stored query:

create or replace view v_b as
  select name, location
  from some_user.table_a;

It would always be "synchronized", you'd instantly see all committed data that belongs to some_user .

A materialized view occupies space, acts as if it was another table - you can even create indexes on it. Set it to refresh in a scheduled manner (for example, every night) or on demand or whenever some_user commits changes made in their table_a .

If I were you, I wouldn't create another table; (materialized) view seems to be a more appropriate solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM