ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Get database name

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get database name

    Hi,

    Trying to understand DB2 architecture better. I am trying to have a front-end application such as vb.net or MS Excel VBA to connect to a DB2 or DB2/400 (which I don't understand the difference or which that I am on). In order to construct my database connection string, how can I find out the database name of my DB2? What command can I run in order to get this name?

    Other additional database info such as Initial Catalog and Package Collection might be of help to me too.
    Thanks All.

  • #2
    Re: Get database name

    From the wiki - There are three main products in the DB2 family:

    DB2 for LUW (Linux, Unix, and Windows)
    DB2 for z/OS (mainframe)
    DB2 for iSeries (formerly OS/400)

    The DB2 LUW product runs on multiple Linux and UNIX distributions, such as Red Hat Linux, SUSE Linux, AIX, HP/UX, and Solaris, and most Windows systems.

    What type of system you are connecting to will tell you what type of DB2 product it is running.

    On an iSeries if you use command WRKPTFGRP you get this display ...
    Code:
    [U]PTF Group             Level  Status   [/U]
    SF99530                8267  Installed
    SF99529                 169  Installed
    SF99519                 110  Installed
    [B]SF99503                  24  Installed
    [/B][I] - - - etc - - - [/I]
    Then if you press F11 you get this additional info ...
    Code:
    [U]PTF Group             Text                            [/U]
    SF99530               CUMULATIVE PTF PACKAGE C8267530 
    SF99529               GROUP HIPER                     
    SF99519               GROUP HIPER                     
    [B]SF99503               DB2 FOR SYSTEM I   [/B]            
    [I] - - - etc - - - [/I]
    Greg Craill: "Life's hard - Get a helmet !!"

    Comment


    • #3
      Re: Get database name

      If you know the name of the system, then you know the name of the database. this is true 99.99% of the time. One system will only have one database and the default is named the same as the system name.

      No clue as to "Initial Catalog and Package Collection".

      But you should build a schema list (on the iseries its referred too as Library list).
      Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

      Comment


      • #4
        Re: Get database name

        WRKRDBDIRE will give you the local database name (by default it's the same as the system name)

        Comment


        • #5
          Re: Get database name

          Thanks a lot, appreciate the helps.
          I can't execute WRKPTFGRP; seem to be user rights issue.
          WRKRDBDIRE returns me a value.
          I am using MAPICS and from it, I pressed F11 key, but the System ID value that was returned is different from WRKRDBDIRE's result. I guess my administrator made mine the 0.01%

          It really helps a lot to know that one single system will only contains one single database. I came from a Wintel and SQL Server where I can have many databases in a single machine.

          Thanks!

          Comment


          • #6
            Re: Get database name

            An IBM i also can have multiple databases (one per IASP - Independent Auxilliary Storage Pool), but most only a sinlge database is used.
            ... but I think we need to clarify or definie the different terms, because IBM i and DB2 for i works different than other databases (even other DB2s!).

            In other databases the terms database or schema are used to define a container containing all database objects such as tables, views, indexes. Quite often the database, schema is identical to an application. If someone connects to the database the user is switched to a database user/authorization id. The name of the default database user is normally identical with the database/schema/application name. This default user is the owner of the database and all objects created within the schema and has all access authority. Other users are not allowed to access the database objects (except they are explicitly granted).

            Since the database on the IBM i is integrated within the operating system, the database objects are accessed by the user that is signed in (and not with a specific database user). Also the IBM i authorities are or must be adopted for the database objects.
            Additionally we normally do not work with a single Default/Current Schema but a list of schemas (called library list).
            For a single program or even SQL select statement quite often tables or views located in different schemas are accessed.

            With "Initial Catalog", I assume you mean the database meta data or information. Those information are stored within catalog views located in the QSYS2 schema/libarary. All available catalog view names start with SYS*.

            Since the database is integrated in the operating system we do not have to care about a lot of things, such as Table Spaces, Buffers, Packages, Statistics, it is handled automatically. Even though an SQL Package could be created, it is (almost) worthless. It will only be used after an IPL (Initial Program Load), if there is no other access plan is found. Even if there is no access plan it will be created by scratch.

            Birgitta

            Comment

            Working...
            X