我需要更新 BigQuery 中 150 多个表的表和列描述。有没有办法编写一个过程,可以循环遍历每个表并更改表并更新表上缺少描述的列的 desc。
我尝试循环遍历每个表,每个表都有 100 多个列。结果每次我都会发布数百个更改。有什么办法可以解决这个问题吗
以下内容将起作用:
FOR row IN (
select "street" as col, "street address" as description
union all
select "city" as col, "city" as description
union all
select "postal_code" as col, "postal code" as description
)
DO
EXECUTE IMMEDIATE FORMAT("""
ALTER TABLE <table_tef>
ALTER COLUMN %s
SET OPTIONS (
description='%s'
);
""", row.col, row.description);
END FOR;
只需调整
<table_ref>
并最好用单个表引用替换我的嵌套 sql 查询(我保持明确 - 所以里面的内容非常清楚)。