Re: Move all elements toward another schema? - Mailing list pgsql-general

From Marcos Pegoraro
Subject Re: Move all elements toward another schema?
Date
Msg-id CAB-JLwYCoLxm-Gxja+LQ8e4yD2JZAFupfditL8FtMHrLbmZ_2Q@mail.gmail.com
Whole thread Raw
In response to Move all elements toward another schema?  (celati Laurent <laurent.celati@gmail.com>)
List pgsql-general
As far as i know, this piece of code would move the data. But how to also move indexes, constraints, primary key?

create schema if not exists a;
create schema if not exists b;
create table a.a(id integer not null constraint pk_a primary key, name text);
create index idx_a_name on a.a(name);
alter table a.a set schema b;

select relnamespace::regnamespace, relname from pg_class where relname in ('a','pk_a','idx_a_name');
 relnamespace |  relname  
--------------+------------
 b            | a
 b            | idx_a_name
 b            | pk_a
(3 rows)
 

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Move all elements toward another schema?
Next
From: "Peter J. Holzer"
Date:
Subject: Re: Quit currently running query