Created
September 22, 2021 07:33
-
-
Save hasanisaeed/babe1892abefedcc9078b4e99aa8a9a8 to your computer and use it in GitHub Desktop.
Postgresql: Change field name in all table.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do | |
$$ | |
declare | |
l_rec record; | |
begin | |
for l_rec in (select table_schema, table_name, column_name | |
from information_schema.columns | |
where table_schema = 'public' | |
and column_name = 'mount') loop | |
execute format ('alter table %I.%I rename column mount to amount', l_rec.table_schema, l_rec.table_name); | |
end loop; | |
end; | |
$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment