Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2011
    Posts
    38

    Unanswered: Getting table structure

    I come from a MySQL background; in MySQL you could easily see the structure of a table by running "EXPLAIN tablename" which would list the columns, their data type, whether they are indexed, etc. How do you do the same thing in DB2? Also where is a good place to search for these basic stuff (searching DB2 documentation is usually helpless)?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Check the DESCRIBE command in the helpless manual.

  3. #3
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    You can use these commands:

    db2 describe table table-name (show detail)
    db2 describe indexes for table table-name (show detail)

    To get the entire schema for a table:

    db2look -d db-name -t table-name -e -a

    The InfoCenter is OK if you know what you are looking for, but the PDF versions of the manuals are also good to browse and search (using PDF search). The most important manuals are these:

    • Command Reference
    • SQL Reference Vol 1 - Select Statement, functions, DB2 catalog
    • SQL Reference Vol 2 - All other SQL
    • Message Reference Vol 2 - SQL Error Messages
    https://www-304.ibm.com/support/docview.wss?rs=71&uid=swg27009474

    PDF Links are at the bottom of the page.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  4. #4
    Join Date
    Apr 2011
    Posts
    38
    Quote Originally Posted by n_i View Post
    Check the DESCRIBE command in the helpless manual.
    The manual is helpless, because I couldn't find my way to "DESCRIBE" using it. A hint from you made it very useful of course. However, I find documentation of some other DBMS more straightforward for non-professional users like me.

Posting Permissions

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