How to get list of database?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Erwin Leonardi

    How to get list of database?

    Hi there,

    Suppose computer PC1 is my database server in which DB2 is running. I
    have an application running in computer PC2. The application PC2 will
    connect to DB2 in PC2.

    How can my application in PC2 get the list of database in PC1? If I
    use MSSQL, I can connect to MASTER database and execute the following
    query.

    SELECT NAME FROM SYS.DATABASES

    Can I do similar thing in DB2?

    Erwin
  • Dave Hughes

    #2
    Re: How to get list of database?

    Erwin Leonardi wrote:
    Hi there,
    >
    Suppose computer PC1 is my database server in which DB2 is running. I
    have an application running in computer PC2. The application PC2 will
    connect to DB2 in PC2.
    >
    How can my application in PC2 get the list of database in PC1? If I
    use MSSQL, I can connect to MASTER database and execute the following
    query.
    >
    SELECT NAME FROM SYS.DATABASES
    >
    Can I do similar thing in DB2?
    There's no equivalent to MS SQL's MASTER database in DB2. AFAIK,
    there's no way to list remote databases either - not unless they
    already exist in the client's local catalog.

    That said, there must be a way as the Control Center is capable of
    listing the databases at a remote node even if they don't exist in the
    local catalog - still, I'm not sure where (or even if) such
    functionality is exposed.


    Cheers,

    Dave.

    Comment

    • Mark A

      #3
      Re: How to get list of database?

      "Erwin Leonardi" <erwinleonardi@ gmail.comwrote in message
      news:f1fe3648-1579-4437-b553-c439f853a146@c6 5g2000hsa.googl egroups.com...
      Hi there,
      >
      Suppose computer PC1 is my database server in which DB2 is running. I
      have an application running in computer PC2. The application PC2 will
      connect to DB2 in PC2.
      >
      How can my application in PC2 get the list of database in PC1? If I
      use MSSQL, I can connect to MASTER database and execute the following
      query.
      >
      SELECT NAME FROM SYS.DATABASES
      >
      Can I do similar thing in DB2?
      >
      Erwin
      Once you ATTACH to the remote instance, issue the command below:

      db2 list db directory

      Ignore the remote databases in the list (if any).


      Comment

      • Dave Hughes

        #4
        Re: How to get list of database?

        Mark A wrote:
        "Erwin Leonardi" <erwinleonardi@ gmail.comwrote in message
        news:f1fe3648-1579-4437-b553-c439f853a146@c6 5g2000hsa.googl egroups.com
        ...
        Hi there,

        Suppose computer PC1 is my database server in which DB2 is running.
        I have an application running in computer PC2. The application PC2
        will connect to DB2 in PC2.

        How can my application in PC2 get the list of database in PC1? If I
        use MSSQL, I can connect to MASTER database and execute the
        following query.

        SELECT NAME FROM SYS.DATABASES

        Can I do similar thing in DB2?

        Erwin
        >
        Once you ATTACH to the remote instance, issue the command below:
        >
        db2 list db directory
        >
        Ignore the remote databases in the list (if any).
        Hmm, doesn't work for me. At least, not when I just tried it from a 9.5
        client to a 9.5 FP1 server. Every single entry was remote - in other
        words, it just listed my local catalog as usual.


        Cheers,

        Dave.

        Comment

        • Mark A

          #5
          Re: How to get list of database?

          "Dave Hughes" <dave@waveform. plus.comwrote in message
          news:U8qdnR-mF_pSkM7VRVnygQ A@posted.plusne t...
          Hmm, doesn't work for me. At least, not when I just tried it from a 9.5
          client to a 9.5 FP1 server. Every single entry was remote - in other
          words, it just listed my local catalog as usual.
          >
          >
          Cheers,
          >
          Dave.
          Sorry, I thought you were ssh'ing (telnet) into the remote server.


          Comment

          Working...