Unix Technical Forum

How to copy tables between databases?

This is a discussion on How to copy tables between databases? within the Pgsql General forums, part of the PostgreSQL category; --> Is there a simple way to copy a table from one database to another without generating an intermediate dump ...


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-10-2008, 12:20 AM
Kynn Jones
 
Posts: n/a
Default How to copy tables between databases?

Is there a simple way to copy a table from one database to another without
generating an intermediate dump file?
TIA!

Kynn

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 12:20 AM
Tom Hart
 
Posts: n/a
Default Re: How to copy tables between databases?

Kynn Jones wrote:
>
>
> Is there a simple way to copy a table from one database to another
> without generating an intermediate dump file?
>
> TIA!
>
> Kynn
>

You're looking for ETL.

http://en.wikipedia.org/wiki/Extract...nsform%2C_load

--
Tom Hart
IT Specialist
Cooperative Federal
723 Westcott St.
Syracuse, NY 13210
(315) 471-1116 ext. 202
(315) 476-0567 (fax)


---------------------------(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
  #3 (permalink)  
Old 04-10-2008, 12:20 AM
Dawid Kuroczko
 
Posts: n/a
Default Re: How to copy tables between databases?

On Tue, Feb 26, 2008 at 9:19 PM, Kynn Jones <kynnjo@gmail.com> wrote:
>
> Is there a simple way to copy a table from one database to another without
> generating an intermediate dump file?


Using UNIX pipes :-)

$ pg_dump ... | psql ...

:-)

Regards,
Dawid

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 12:20 AM
Richard Huxton
 
Posts: n/a
Default Re: How to copy tables between databases?

Kynn Jones wrote:
> Is there a simple way to copy a table from one database to another without
> generating an intermediate dump file?


Something along the lines of:
pg_dump ... -d db1 --table=mytable | psql -d db2

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 12:20 AM
Uwe C. Schroeder
 
Posts: n/a
Default Re: How to copy tables between databases?


On Tuesday 26 February 2008, Kynn Jones wrote:
> Is there a simple way to copy a table from one database to another without
> generating an intermediate dump file?
> TIA!
>
> Kynn



pg_dump -t [table] [database] | psql -U [remoteuser] -h [remotehost]
[remotedatabase]

comes to mind...

You can and maybe have to add more switches to the pg_dump command, but the
above is what I'm doing (my local db is set to trust) to copy a table with
data to a remote machine

Uwe

--
Open Source Solutions 4U, LLC 1618 Kelly St
Phone: +1 707 568 3056 Santa Rosa, CA 95401
Cell: +1 650 302 2405 United States
Fax: +1 707 568 6416

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-10-2008, 12:20 AM
Brad Nicholson
 
Posts: n/a
Default Re: How to copy tables between databases?

On Tue, 2008-02-26 at 15:19 -0500, Kynn Jones wrote:
>
> Is there a simple way to copy a table from one database to another
> without generating an intermediate dump file?
>


pg_dump -t <table name> <source DB> | psql -d <target DB>
--
Brad Nicholson 416-673-4106
Database Administrator, Afilias Canada Corp.



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-10-2008, 12:20 AM
Scott Marlowe
 
Posts: n/a
Default Re: How to copy tables between databases?

On Tue, Feb 26, 2008 at 2:36 PM, Brad Nicholson
<bnichols@ca.afilias.info> wrote:
> On Tue, 2008-02-26 at 15:19 -0500, Kynn Jones wrote:
> >
> > Is there a simple way to copy a table from one database to another
> > without generating an intermediate dump file?
> >

>
> pg_dump -t <table name> <source DB> | psql -d <target DB>


Starting around 8.2 you can have > 1 -t switch, and grab a table or a
wildcarded set of tables with each one.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

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 07:53 PM.


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