Re: pg_restore without dropping db/table

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: pg_restore without dropping db/table
Дата
Msg-id 56E1B4A0.4030104@aklaver.com
обсуждение исходный текст
Ответ на Re: pg_restore without dropping db/table  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Ответы Re: pg_restore without dropping db/table  (Melvin Davidson <melvin6925@gmail.com>)
Список pgsql-general
On 03/10/2016 09:41 AM, Karsten Hilbert wrote:
> On Thu, Mar 10, 2016 at 10:51:05AM -0500, anj patnaik wrote:
>
>> Does pg_restore only add new rows if I restore without deleting old db?
>
> No. For one thing, pg_restore cannot know what you consider
> to be a "new row".

If you however do know what is new is then you might want to look at:

COPY
http://www.postgresql.org/docs/9.5/interactive/sql-copy.html
<<IMPORTANT>>
"COPY with a file name instructs the PostgreSQL server to directly read
from or write to a file. The file must be accessible by the PostgreSQL
user (the user ID the server runs as) and the name must be specified
from the viewpoint of the server. When PROGRAM is specified, the server
executes the given command and reads from the standard output of the
program, or writes to the standard input of the program. The command
must be specified from the viewpoint of the server, and be executable by
the PostgreSQL user. When STDIN or STDOUT is specified, data is
transmitted via the connection between the client and the server."

Or you can use the psql variant \copy

http://www.postgresql.org/docs/9.5/interactive/app-psql.html

"Performs a frontend (client) copy. This is an operation that runs an
SQL COPY command, but instead of the server reading or writing the
specified file, psql reads or writes the file and routes the data
between the server and the local file system. This means that file
accessibility and privileges are those of the local user, not the
server, and no SQL superuser privileges are required."


In either case you can craft a query to limit the rows copied. The issue
is that this assumes the both databases are static over the time you do
this.

Your other options are to use replication:

http://www.postgresql.org/docs/9.5/interactive/high-availability.html

or FDW

https://wiki.postgresql.org/wiki/Foreign_data_wrapper

>
> Best,
> Karsten
>


--
Adrian Klaver
adrian.klaver@aklaver.com


В списке pgsql-general по дате отправления:

Предыдущее
От: Karsten Hilbert
Дата:
Сообщение: Re: pg_restore without dropping db/table
Следующее
От:
Дата:
Сообщение: Re: Re: "missing chunk number XX for toast value YY in pg_toast ..." after pg_basebackup.