I am trying to update all tables starting with string like \'agg%\' and column_name =\'%userid%\'... But i dont see any such examples online even though i was able to find o
To get the update query for your condition
select
'update '||c.table_name||' set '||c.COLUMN_NAME||' = ''rajeev'';'
as my_update_query
from
(select
table_name,COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS
where table_name LIKE 'agg%' and COLUMN_NAME LIKE '%userid%') c
To execute
do $$
declare
arow record;
begin
for arow in
select
'update '||c.table_name||' set '||c.COLUMN_NAME||' = ''rajeev'';'
as my_update_query
from
(select
table_name,COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS
where table_name LIKE 'agg%' and COLUMN_NAME LIKE '%userid%') c
loop
execute arow.my_update_query;
end loop;
end;
$$;