If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > SELECT INTO - referencing table from external database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-12-11, 12:54
krontrex krontrex is offline
Registered User
 
Join Date: Sep 2010
Posts: 37
SELECT INTO - referencing table from external database

I want to copy a table from one database into the other one.
I found this
Code:
SELECT * INTO new_table_name [IN externaldatabase] FROM old_tablename
Myproblem is how to reference externaldatabase I tried with "database2.schemat2.new_table_name" but it did not work. database2 runs at the same server as database1 containing old_table_name so the user, password, port, host is the same for both databases.
Is there any other way to do this (except pg_dump)?
Thanks
Reply With Quote
  #2 (permalink)  
Old 10-13-11, 07:42
shureg shureg is offline
Registered User
 
Join Date: Oct 2011
Location: Hamburg, Germany
Posts: 15
in oracle you do it like

from tab@db
i think in postgresql you can do it similar
Reply With Quote
  #3 (permalink)  
Old 11-12-11, 05:57
Wedgetail Wedgetail is offline
Registered User
 
Join Date: Feb 2009
Posts: 29
Hi Krontrex,

I did not think it was possible to copy from one database to another in PostgreSQL. However, I dont know all the available options.

If
Quote:
SELECT * INTO new_table_name [IN externaldatabase] FROM old_tablename
works, then the syntax you are after would be:

Quote:
SELECT * INTO "NewSchema"."New_table_name" IN "NewDatabase" FROM "OriginalSchema"."OriginalTable";
That statement would need to be run from the Original Database.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On