Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help: Copy data from table to table within different DB, How? (PostgreSQL)

    Hi,
    I'm using PHP with PostgreSQL.

    To copy data from one table to another table within the same database can use the following query:
    INSERT INTO table2 SELECT * FROM table1 WHERE field1='value1';

    My question is:
    I have to copy data from one database's table to another database's table, and I was wondering if there is any way to do that than to have a lot of inserts one after another?

    Thanks.

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    you should probably be able to do that the same way as you do with tables in the same database. your permissions would have to allow you to do that of course.

    you would have to refer to your tables by appending the appropriate database name as well:

    databasename1.tablenameA
    databasename2.tablenameR

    for instance.

  • #3
    New Coder
    Join Date
    Dec 2005
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Looks like it doesn't work. It returned me this error:
    ERROR: cross-database references are not implemented: "database1.public.table1"

    Can I change any setting to allow cross-database references? Or is there any other suggestion?


  •  

    Posting Permissions

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