舉個例子
select table_name from information_schema.columns
把這個結果當成函式的陣列引數
CREATE OR REPLACE FUNCTION fff(count integer, table_name_ary text[])
RETURNS void
AS $$
declare
d_table_name text = null;
begin
for i in 1..count loop
d_table_name = table_name_ary[i];
ALTER TABLE d_table_name
ADD test_column text not null default '';
end loop;
end
$$ language plpgsql;
uj5u.com熱心網友回復:
select ARRAY_AGG(distinct table_name) from (select distinct table_name from information_schema.columns) T;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/18260.html
標籤:PostgreSQL
上一篇:求助資料庫樹形結構查詢問題
下一篇:fetch時報243錯誤
