Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010

    Unanswered: SELECT INTO - referencing table from external database

    I want to copy a table from one database into the other one.
    I found this
    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)?

  2. #2
    Join Date
    Oct 2011
    Hamburg, Germany
    in oracle you do it like

    from tab@db
    i think in postgresql you can do it similar

  3. #3
    Join Date
    Feb 2009
    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.

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

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts