簡體   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