繁体   English   中英

重命名 SQL 表中的所有列名称

[英]Rename all column names inside a SQL table

我有一个关于雪花的表,它有超过 100 列,我想为所有列名添加一个后缀“_LA”。 在 sql 中有什么简单的方法可以做到这一点吗?

此脚本为给定 schema.table 名称的所有列生成 alter 命令:

  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;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM