From: | Melvin Davidson <melvin6925(at)gmail(dot)com> |
---|---|
To: | Francisco Olarte <folarte(at)peoplecall(dot)com> |
Cc: | Juliano <jplinux(at)protonmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Overwrite pg_catalog? |
Date: | 2016-12-01 14:11:03 |
Message-ID: | CANu8Fixdk_mFeZHXppNWF=E1hRm5JoOQXUvDh_Xu8c+aEbvk-A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Dec 1, 2016 at 7:07 AM, Francisco Olarte <folarte(at)peoplecall(dot)com>
wrote:
> Juliano:
>
> On Thu, Dec 1, 2016 at 12:16 PM, Juliano <jplinux(at)protonmail(dot)com> wrote:
> > I tried to restore pg_catalog to my new database, but the existing
> > pg_catalog can't be overwritten or dropped, and postgres auto creates
> > pg_catalog when I create a new DB.
>
> This is because, in general, pg_catalog is maintained by DML
> statements, restoring it is not going to do what you think.
>
> I.e., if you create a table, a row goes into pg_class, but if you
> somehow manage to insert into pg_class a table is not properly created
> ( more things need to be done ).
>
> Copying pg_catalog from one db to other is like trying to copy the
> root dir and FAT from one floppy ( how old fashioned ) to other, it
> cannot be done with normal tools and probably won't do what you think
> it does.
>
>
> > So, there is a way to restore the pg_catalog to a new database?
>
> Probably not, but this has the faint smell of http://xyproblem.info/ ,
> what are you truing to achieve by doing that?
>
> Francisco Olarte.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
*Juliano,*
*The right way to do what you want is to:*
*A:*
*1. pg_dump from the database you want to copy
https://www.postgresql.org/docs/9.6/static/app-pgdump.html
<https://www.postgresql.org/docs/9.6/static/app-pgdump.html>*
*2. pg_restore the dump file too the new database.
https://www.postgresql.org/docs/9.6/static/app-pgrestore.html
<https://www.postgresql.org/docs/9.6/static/app-pgrestore.html>*
*OR*
*B:*
*1: pg_dumpall from the cluster you want to copy
https://www.postgresql.org/docs/9.6/static/app-pg-dumpall.html
<https://www.postgresql.org/docs/9.6/static/app-pg-dumpall.html>*
*2: use psql to restore the dump file into the new cluster
https://www.postgresql.org/docs/9.6/static/app-psql.html
<https://www.postgresql.org/docs/9.6/static/app-psql.html>*
--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-12-01 15:00:24 | Re: issue with host name lookup in PQconnectdb |
Previous Message | Robert Inder | 2016-12-01 13:55:39 | Moving pg_xlog |