📜  更改所有表 postgres 的架构 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:04:58.199000             🧑  作者: Mango

代码示例1
DO
$$DECLARE
   p_table regclass;
BEGIN
   SET LOCAL search_path='xyz';
   FOR p_table IN
      SELECT oid FROM pg_class
      WHERE relnamespace = 'xyz'::regnamespace
        AND relkind = 'r'
   LOOP
      EXECUTE format('ALTER TABLE %s SET SCHEMA public', p_table);
   END LOOP;
END;$$;