in the database postgres, there is a table base1that is the base table for presentation view1.
if a column in base1is created, dropped, or renamed, I would like to recreate the view view1using a ddl trigger.
create event trigger base1_views
on ddl_command_end
when tag in( 'ALTER TABLE' )
execute procedure base1_views_fn();
create function base1_views_fn() returns void as $$
declare
buf varchar;
begin
buf = 'drop view view1';
execute buf;
buf = 'create view view1 as select * from base1 where ...';
execute buf;
end;
$$ language 'plpgsql';
inside the function base1_views_fn(), how do we get the table name and change the columns?
source
share