Unix Technical Forum

copy data between database

This is a discussion on copy data between database within the Pgsql General forums, part of the PostgreSQL category; --> Hi, I have a table A in both database d1 and d2. I would like to copy data in ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 06:16 AM
autogoor@yahoo.com
 
Posts: n/a
Default copy data between database

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,


Thanks,

Goor

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 06:16 AM
Hannes Dorbath
 
Posts: n/a
Default Re: copy data between database

Never used it, but look at contrib/dblink and better use different
schemas instead of different databases in future -- if you want to
exchange data.

On 07.10.2005 03:55, 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,


--
Regards,
Hannes Dorbath
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 06:17 AM
Qingqing Zhou
 
Posts: n/a
Default Re: copy data between database


<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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 06:19 AM
Scott Marlowe
 
Posts: n/a
Default Re: copy data between database

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.

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-09-2008, 06:20 AM
Qingqing Zhou
 
Posts: n/a
Default Re: copy data between database


"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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-09-2008, 06:20 AM
Scott Marlowe
 
Posts: n/a
Default Re: copy data between database

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.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:44 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com