Accessing tables from different databases

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • K. Deepa

    Accessing tables from different databases

    Hi all,
    I want to access a table-1 of database-1 from
    database-2. Is it possible in pgsql. If so,
    is it possible to define a foreign key constraint
    for a column in table-2 in database-2 which
    references to a column in table-1 in database-1.
    TIA

    regards,
    Deepa K.



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



  • Shridhar Daithankar

    #2
    Re: Accessing tables from different databases

    K. Deepa wrote:[color=blue]
    > Hi all,
    > I want to access a table-1 of database-1 from
    > database-2. Is it possible in pgsql. If so,[/color]

    Yes. You need to use dblink contrib module for that.
    [color=blue]
    > is it possible to define a foreign key constraint
    > for a column in table-2 in database-2 which
    > references to a column in table-1 in database-1.[/color]

    I am afraid that's not possible.

    Shridhar


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



    Comment

    • Fernando Schapachnik

      #3
      Re: Accessing tables from different databases

      Look at contrib/dblink.

      Regards.

      Fernando.
      En un mensaje anterior, K. Deepa escribió:[color=blue]
      > Hi all,
      > I want to access a table-1 of database-1 from
      > database-2. Is it possible in pgsql. If so,
      > is it possible to define a foreign key constraint
      > for a column in table-2 in database-2 which
      > references to a column in table-1 in database-1.
      > TIA[/color]

      ---------------------------(end of broadcast)---------------------------
      TIP 1: subscribe and unsubscribe commands go to majordomo@postg resql.org

      Comment

      • Tom Lane

        #4
        Re: Accessing tables from different databases

        Fernando Schapachnik <fernando@mecon .gov.ar> writes:[color=blue]
        > En un mensaje anterior, K. Deepa escribió:[color=green]
        >> I want to access a table-1 of database-1 from
        >> database-2. Is it possible in pgsql. If so,[/color][/color]
        [color=blue]
        > Look at contrib/dblink.[/color]

        Also consider the possibility of using multiple schemas in a single
        database, rather than a multi-database installation.

        regards, tom lane

        ---------------------------(end of broadcast)---------------------------
        TIP 8: explain analyze is your friend

        Comment

        • Pavel Stehule

          #5
          Re: Accessing tables from different databases

          Hello,

          You can acces others db via dblink. You will find it in contrib.
          You can't use dblink for define f.k. :-(

          regars
          Pavel

          [color=blue]
          > Hi all,
          > I want to access a table-1 of database-1 from
          > database-2. Is it possible in pgsql. If so,
          > is it possible to define a foreign key constraint
          > for a column in table-2 in database-2 which
          > references to a column in table-1 in database-1.
          > TIA
          >
          > regards,
          > Deepa K.
          >
          >
          >
          > ---------------------------(end of broadcast)---------------------------
          > TIP 6: Have you searched our list archives?
          >
          > http://archives.postgresql.org
          >[/color]


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

          Comment

          Working...