Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2006
    Posts
    13

    Question Unanswered: how do get database alias from snapshot functions

    Hi
    I need to get the alias for a database.
    I am using following query. But the query returns '-'.

    My db2version is 8.2

    select INPUT_DB_ALIAS from TABLE (snapshot_database(cast (NULL as varchar(8)) , -2 )) as database

    any idea how to get the database alias

    Thanks in advance

    subbu

  2. #2
    Join Date
    Oct 2004
    Location
    DELHI INDIA
    Posts
    338
    Just run the command : db2 "list db directory"

    It will tell you the name of the database as well as the corresponding Alias name.

    Thanks,
    Jayanta
    New Delhi, India

  3. #3
    Join Date
    Mar 2006
    Posts
    13
    Thanks
    any idea why the query is not returning the alias name.

    "select INPUT_DB_ALIAS from TABLE (snapshot_database(cast (NULL as varchar(8)) , -2 )) as database"

    I have my db2 on windows.

  4. #4
    Join Date
    Jun 2001
    Posts
    20
    Try "select INPUT_DB_ALIAS from TABLE (snapshot_database('', -2 )) as database"
    Renga

  5. #5
    Join Date
    Mar 2006
    Posts
    13
    The query returns only database name and not alias name.

  6. #6
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    My guess is that you are connected to a database locally and there is no alias such as would be used for a remote connection (the alias is the same as the database and a null value is being returned).

    You could use:

    select coalesce(INPUT_DB_ALIAS, DB_NAME) from TABLE (snapshot_database(cast (NULL as varchar(8)) , -2 )) as database

    This would return the DB_NAME if INPUT_DB_ALIAS is null.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  7. #7
    Join Date
    Mar 2006
    Posts
    13
    Hi

    I am connected to remote database using CLP.The database is catalogued using the alias name.My application requires getting both alias name as well as database name.

    List database directory returns only alias name for both alias name and database name.

    eg I have a database X which is given an alias name Y. So if i have to connect to the database i need to catalog it using alias name.

    So how do i get both alias name and database name using the query since the "list datase directory" from a remote host returns only alias name.

    Thanks in advance

Posting Permissions

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