Re: Move all elements toward another schema?

From: Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>
To: celati Laurent <laurent(dot)celati(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Move all elements toward another schema?
Date: 2023-02-28 16:51:19
Message-ID: CAB-JLwYCoLxm-Gxja+LQ8e4yD2JZAFupfditL8FtMHrLbmZ_2Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter J. Holzer 2023-02-28 17:31:45 Re: Quit currently running query
Previous Message David G. Johnston 2023-02-28 16:44:45 Re: Move all elements toward another schema?