postgresql 根据一个schema 创建另一个 schema 包含原schema 所有的表
1 DO $$ 2 DECLARE 3 tbl_name text; 4 BEGIN 5 FOR tbl_name IN 6 SELECT table_name 7 FROM information_schema.tables 8 WHERE table_schema = 'public' 9 LOOP 10 EXECUTE 'CREATE TABLE account2024.' || tbl_name || '() INHERITS (public.' || tbl_name || ')'; 11 END LOOP; 12 END $$;