postgresql - How to execute query statements generated in pgAdmin4? -


i have following query generates list of alter table statements in 'data output' field in pgadmin4. can copy & paste them query pane , execute them there.

select 'alter table ' || table_name || ' owner myuser;' information_schema.tables table_schema = 'public'; 

how can execute generated statements without having copy & paste them?

you can use function that.

create or replace function change_permission_table()  returns void $$ declare     rec text; begin     rec in select 'alter table ' || table_name || ' owner maz;' information_schema.tables table_schema = 'public'     loop        execute rec;     end loop; end; $$ language plpgsql;  -- run function change permission select change_permission_table() 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -