Good afternoon,
As far as i know, this piece of code would move the data. But how to also move indexes, constraints, primary key?
DO
$$
DECLARED
row record;
BEGIN
FOR row IN SELECT tablename FROM pg_tables WHERE schemaname = 'A' -- and other conditions, if needed
LOOPS
EXECUTE format('ALTER TABLE A.%I SET SCHEMA [B];', row.tablename);
END LOOP;
END;
$$;
$$
DECLARED
row record;
BEGIN
FOR row IN SELECT tablename FROM pg_tables WHERE schemaname = 'A' -- and other conditions, if needed
LOOPS
EXECUTE format('ALTER TABLE A.%I SET SCHEMA [B];', row.tablename);
END LOOP;
END;
$$;
Thanks so much.