Results 1 to 5 of 5

Thread: Query to get table structure

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Answers
    13

    Unhappy Query to get table structure

    Hi friends, i want a query to know the table structure in db2 listing all its columns, primary keys and all. I tried using the query describe table table_name i get the following o/p --------------------- column type type name schema name length scale nulls ------------------------------ --------- ------------------ -------- ---- 0 record(s) selected. Sql0100w no row was found for fetch, update or delete; or the result of a query is an empty table. Sqlstate=02000 please help me.


  2. #2
    Contributing Member
    Join Date
    Sep 2005
    Answers
    91

    Re: Query to get table structure

    The following example shows how to describe a SELECT statement:

    db2 "describe output select * from staff" SQLDA Information

    sqldaid :SQLDA sqldabc:896 sqln:20 sqld:7

    Column Information

    sqltype sqllen sqlname.data sqlname.length
    -------------------- ------ ------------------------------ --------------
    500 SMALLINT 2 ID 2
    449 VARCHAR 9 NAME 4
    501 SMALLINT 2 DEPT 4
    453 CHARACTER 5 JOB 3
    501 SMALLINT 2 YEARS 5
    485 DECIMAL 7,2 SALARY 6
    485 DECIMAL 7,2 COMM 4


  3. #3
    Junior Member
    Join Date
    Sep 2007
    Answers
    13

    Smile Re: Query to get table structure

    Quote Originally Posted by Beena View Post
    The following example shows how to describe a SELECT statement:

    db2 "describe output select * from staff" SQLDA Information

    sqldaid :SQLDA sqldabc:896 sqln:20 sqld:7

    Column Information

    sqltype sqllen sqlname.data sqlname.length
    -------------------- ------ ------------------------------ --------------
    500 SMALLINT 2 ID 2
    449 VARCHAR 9 NAME 4
    501 SMALLINT 2 DEPT 4
    453 CHARACTER 5 JOB 3
    501 SMALLINT 2 YEARS 5
    485 DECIMAL 7,2 SALARY 6
    485 DECIMAL 7,2 COMM 4


    Thanks Beena. Is there any query describing the primary keys of the table??


  4. #4
    Junior Member
    Join Date
    May 2008
    Answers
    2

    Re: Query to get table structure

    You can use describe indexes for table <<< table name>>> show detail thank you


  5. #5
    Junior Member
    Join Date
    May 2008
    Answers
    4

    Re: Query to get table structure

    Hi,
    As per my knowledge you have searched for the table which is not available.
    If you use the bellow mentioned query then it will definitely work.
    $ db2 "describe table schema-name.table-name"
    Please check the table is cataloged or not...
    Regards,
    Shubhrojyoti
    dbashubhrojyoti@gmail.com

    Last edited by dbadb2udb; 05-26-2008 at 04:02 PM.

  6.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact