Answers for "change schema of all tables postgres"

SQL
0

change schema of all tables postgres

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;$$;
Posted by: Guest on September-11-2020

Code answers related to "change schema of all tables postgres"

Code answers related to "SQL"

Browse Popular Code Answers by Language