Restore data to an existing populated table

From: Renato Oliveira <renato(dot)oliveira(at)grant(dot)co(dot)uk>
To: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Restore data to an existing populated table
Date: 2010-04-08 08:40:58
Message-ID: 7965A9DCF12CC14984420BCC37B1608F25ABF311FB@Elzar.grant.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Dear all,

I would like to know if it is possible to restore data to a pre-populated db/table.

I was reading the man pages for pg_dump and pg_restore.

"The limitations of pg_restore are detailed below.

* When restoring data to a pre-existing table and the option...

Does that mean the table can exist and can be populated with data, pg_restore will append the data to the db/table without deleting/dropping the existing data?

What I need to achieve is:
1 - Download the schema from an old DB
2 - Restore the schema to a new DB
3 - Point my application to the new DB, it will populate with new data
4 - at later date do a pg_dump to dump the data from old DB - (Should I use 'COPY' statement instead of pg_dump?
5 - Restore the data only to the new DB - as in copying the data and appending it to existing db/tables.

What is the natural behaviour of pg_restore, does it wipe the existing data on the existing DB, or it displays 'errors' and carries on copying the data?

I read there are ways of copying the data using 'COPY' statements, does that mean I can copy the data back without wiping the existing data?

Ps Thank you very much for all help you have given to me, and all the time you spent reading and also replying to my emails.
I am learning loads, still loads to learn but I am sure some day I will be helping as well.

Thank you very much

Best regards

Renato

Renato Oliveira
Systems Administrator
e-mail: renato(dot)oliveira(at)grant(dot)co(dot)uk

Tel: +44 (0)1763 260811
Fax: +44 (0)1763 262410
www.grant.co.uk<http://www.grant.co.uk/>

Grant Instruments (Cambridge) Ltd

Company registered in England, registration number 658133

Registered office address:
29 Station Road,
Shepreth,
CAMBS SG8 6GB
UK

P Please consider the environment before printing this email
CONFIDENTIALITY: The information in this e-mail and any attachments is confidential. It is intended only for the named recipients(s). If you are not the named recipient please notify the sender immediately and do not disclose the contents to another person or take copies.

VIRUSES: The contents of this e-mail or attachment(s) may contain viruses which could damage your own computer system. Whilst Grant Instruments (Cambridge) Ltd has taken every reasonable precaution to minimise this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should therefore carry out your own virus checks before opening the attachment(s).

OpenXML: For information about the OpenXML file format in use within Grant Instruments please visit our website<http://www.grant.co.uk/Support/openxml.html>

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Andreas 'ads' Scherbaum 2010-04-08 08:52:49 Re: Database level encryption
Previous Message Greg Stark 2010-04-08 04:59:12 Re: PD_ALL_VISIBLE flag warning