I have a table on snowflake which has more than 100 columns, and I would like to add a suffix '_LA' to all the column names. Is there any easy way to do this in sql?
this script produce alter command for all columns of given schema.table name:
select 'ALTER TABLE ' || table_schema || '.' || table_name || ' RENAME COLUMN ' || column_name || ' TO _LA' || column_name
from information_schema.columns
where table_schema ilike 'schema' -- put your schema name here
and table_name ilike 'table' -- put your table name here
order by ordinal_position;
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.