Thread: Re: copy data between database

Re: copy data between database

From
"Qingqing Zhou"
Date:
<autogoor@yahoo.com> wrote
> Hi, I have a table A in both database d1 and d2. I would like to copy
> data in A in d1 to A in d2. How can I do it? I do not want to copy all
> data, just some part of A,
>
>

Here is a way if you feel want to try. The basic idea is that create a table
(say OS file name of this table is xxx) for the part of data of A that you
are interested in d1, and create another table of the same structure in d2
but empty with OS file name yyy. Then normally shutdown database, replace
yyy with xxx. Restart database again, you will get the data in d2. Notice
that you must make sure that two database d1 and d2 are initialized with the
same parameters.

Regards,
Qingqing



Re: copy data between database

From
Scott Marlowe
Date:
On Fri, 2005-10-07 at 21:34, Qingqing Zhou wrote:
> <autogoor@yahoo.com> wrote
> > Hi, I have a table A in both database d1 and d2. I would like to copy
> > data in A in d1 to A in d2. How can I do it? I do not want to copy all
> > data, just some part of A,
> >
> >
>
> Here is a way if you feel want to try. The basic idea is that create a table
> (say OS file name of this table is xxx) for the part of data of A that you
> are interested in d1, and create another table of the same structure in d2
> but empty with OS file name yyy. Then normally shutdown database, replace
> yyy with xxx. Restart database again, you will get the data in d2. Notice
> that you must make sure that two database d1 and d2 are initialized with the
> same parameters.

Under no circumstances should you do this with a database that has any
data in it that you value.  pg_dump / pg_restore / psql are the
preferred way of doing this.

Note that for what is being done here, slony would be a great fit as
well, and now that it's available as an rpm, it should be pretty easy to
setup and use.

Re: copy data between database

From
"Qingqing Zhou"
Date:
"Scott Marlowe" <smarlowe@g2switchworks.com> wrote
>
> Under no circumstances should you do this with a database that has any
> data in it that you value.  pg_dump / pg_restore / psql are the
> preferred way of doing this.
>

Oh yeah, sorry for the miss leading information. My method is dangerous and
can not cover all the cases (say you have an external stored column, etc).

Sorry about it,
Qingqing



Re: copy data between database

From
Scott Marlowe
Date:
On Mon, 2005-10-10 at 13:53, Qingqing Zhou wrote:
> "Scott Marlowe" <smarlowe@g2switchworks.com> wrote
> >
> > Under no circumstances should you do this with a database that has any
> > data in it that you value.  pg_dump / pg_restore / psql are the
> > preferred way of doing this.
> >
>
> Oh yeah, sorry for the miss leading information. My method is dangerous and
> can not cover all the cases (say you have an external stored column, etc).
>
> Sorry about it,
> Qingqing

No need to apologize.  I do that same kind of thing all the time.  Just
not on production servers is all.