CREATE OR REPLACE FUNCTION "ods"."transbln"() RETURNS "pg_catalog"."void" AS $BODY$ DECLARE v_rec record; BEGIN -- ================================================================================== -- 让读书成为一种生活方式。就像吃喝拉撒每天必须要干的事, -- 终有一天你的举止、言谈、气质会不一样。 -- —- async -- -- Created Date: Sunday, 2020-05-19, 3:48:04 pm -- copyright (c): SZWW Tech. LTD. -- Engineer: async -- Module Name: -- Revision: v0.01 -- Description: -- -- Revision History : -- Revision editor date Description -- v0.01 async 2020-05-19 File Created -- ================================================================================== FOR v_rec IN( SELECT 'alter table '||table_schema||'.'||table_name||' rename column '||'"'||column_name||'"'||' to ' ||lower(column_name)||';' as alt_col FROM information_schema.columns ma where ma.table_schema='ods' and column_name<> lower(column_name) )loop RAISE INFO '%: %', clock_timestamp(), v_rec.alt_col; execute v_rec.alt_col; END loop; EXCEPTION WHEN OTHERS THEN RAISE EXCEPTION '(%:%:%)',clock_timestamp(), sqlerrm; END; $BODY$ LANGUAGE plpgsql VOLATILE COST 100