Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2003
    Location
    Denmark
    Posts
    4

    Question Unanswered: How can I "select" from a table stored in another postgresql database?

    How can I "select" from a table stored in another postgresql database?

    I've tried this:

    select id
    from database2.table

    But I get this error-message:

    ERROR: Namespace "database2" does not exist!

    The database2 is created and have the the table "table" in it.

    Anyone got a solution?

    thx in advance!

  2. #2
    Join Date
    Sep 2001
    Location
    Vienna
    Posts
    400

    select from 2 databases

    You cannot select from 2 databases without compiling dblink

    dblink is in the contrib in the sources
    http://www.postgresql.org
    --Postgresql is the only kind of thing--

  3. #3
    Join Date
    Oct 2003
    Location
    Denmark
    Posts
    4
    oki ... any documentation on how the sql-syntax is when using dblink ?

  4. #4
    Join Date
    Sep 2001
    Location
    Vienna
    Posts
    400

    dblink

    ther are examples and a small doku directly in the dblink directory
    http://www.postgresql.org
    --Postgresql is the only kind of thing--

  5. #5
    Join Date
    Oct 2003
    Location
    Denmark
    Posts
    4

    dblink.sql

    i'm having some problems running the dblink.sql script:

    CREATE FUNCTION dblink (text,text) RETURNS setof int
    AS '??','dblink' LANGUAGE 'c';

    CREATE FUNCTION dblink_tok (int,int) RETURNS text
    AS '??','dblink_tok' LANGUAGE 'c';

    what should the ?? be ... ?? '/usr/local/lib/dblink.so' ??

  6. #6
    Join Date
    Sep 2001
    Location
    Vienna
    Posts
    400

    no problem

    Installation:
    Place these files in a directory called 'dblink' under 'contrib' in the PostgreSQL source tree. Then run:

    make
    make install

    You can use dblink.sql to create the functions in your database of choice, e.g.

    psql -U postgres template1 < dblink.sql

    ------------------------------------------------------------------------
    README.dblink
    http://www.postgresql.org
    --Postgresql is the only kind of thing--

  7. #7
    Join Date
    Oct 2003
    Location
    Denmark
    Posts
    4

    Talking

    hehe ... found the problem!

    I'm using Postgres 7.3.2 but I was trying to install dblink for PG 7.2.3

    ARRRGHH

    Got it 2 work with the right version ....

    thx 4 u're help

Posting Permissions

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