Home > AS/400 Tips > iSeries administrator tips > How to use DB2's cross-reference files to help manage your database -- Part I
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES ADMINISTRATOR TIPS

How to use DB2's cross-reference files to help manage your database -- Part I


Ron Turull
06.09.2004
Rating: -4.52- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



[IMAGE]
[IMAGE][IMAGE]
Ron Turull [IMAGE]
[IMAGE]

DB2 maintains a number of cross-reference files that you can use to easily retrieve information about files on your system. They contain information on files, fields, keys, referential constraints and much more, and they are easy the work with. The cross-reference files are automatically updated by the system any time changes are made to the structure of the iSeries-AS/400 database (which includes such things as creating a new file physical or logical file, changing an existing file, adding and/or removing referential constraints, etc.).

Eight cross-reference files

There are eight cross-reference physical files, each containing a different type of information.

  1. QADBXREF. This is the main cross-reference file. Although it doesn't "cross-reference" a whole lot, it does contain attributes for every database file on the system, attributes such as the following:

    * Physical file, logical file, table, view, or index
    * Number of fields
    * Number of key fields
    * Record length

    The QADBXREF file is like a header file for most of the other DB2 cross-reference files.

  2. More information


    [IMAGE]

  3. QADBFDEP. This file holds the information displayed on the DSPDBR command -- information about dependent files (e.g., logical files).

  4. QADBIFLD. This file contains information about every field in every file on the system. It can be used to find field name conflicts, create customized field description reports and more.

  5. QADBKFLD. Combined with the QADBIFLD file, these two files are a goldmine. QADBKFLD holds information about all the key fields used in files that have keyed access paths.

  6. QADBFCST. This is the header file for referential constraint information. It contains file-level information about the constraints that have been added to files on the system. The detail file is QADBCCST (see next).

  7. QADBCCST. This is the detail file for referential constraint information. It contains the field-level information about referential constraints. You can "link" it to the header file using the field information shown in the table below.

    QADBFCST fields QADBCCST fields
    DBCCFL DBCCLN
    ...

    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



    RELATED CONTENT
    Systems Management
    Can you trust all those trigger programs?
    Are your backups complete?
    Controlling remote command processing
    Watch your profiles
    Avoid locking issues
    Send message to users at a remote site
    Security journal receiver management
    Top 10 backup commands
    Tracking critical file access in real time
    Create an iSeries Access image and update it with the latest Service Pack

    DB2 UDB for iSeries
    Expert advice on DB2
    Make your database easy to read
    Top 10 tips from our experts
    DB2 expert Kent Milligan offers advice
    Schedule stored procedures in DB2 UDB
    Special features make creating tables simple
    How to use DB2's cross-reference files to help manage your database -- Part II
    Revisit your database naming conventions
    DB2/400 and DB2 UDB
    'Twas the Night Before Christmas in IT

    iSeries administrator tips
    Translating Linux for IBM i admins: Using GUI to make it easy
    Translating Linux for IBM i admins: Working with jobs and networking
    OpenOffice: What to know before making the transition from Microsoft Office
    OpenOffice: An enterprise open source solution
    Database performance comparisons on IBM i
    Translating Linux for IBM i admins: User profile commands
    Modern System i reports using Client Access
    Tips for installing Lotus Domino server on a System i partition
    The iSeries Blog has a new home on IT Knowledge Exchange
    Virtualization for IBM i: Backups

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary


    DBCCFF DBCCFN
    DBCCNL DBCCKL
    DBCCNM DBCCKN

  8. QADBPKG. This file contains information on SQL packages that have been created on the system. The Consistency token field (DBPTKN) contains the package's "signature," similar in concept to export signatures for ILE service programs and level identifiers for files.

  9. QADBXRDBD. This file maintains information about the relational database definitions present on your system. Relational database definitions are most commonly used in SQL.

To get more information on these files, you can use the Display file field description command (DSPFFD) to display or print the field definitions. Then use Query/400, SQL or some other query tool to examine the contents.

How to access the data

You can access the data in the files directly or you can build your own logical files over these files so you can access the data in whatever way suits your needs. However, each physical file may have one or more logical files already built over it, so before you build any new logical files over these cross-reference files, use the utility presented later to check if a logical file with the appropriate key already exists. SQL users should also note that in addition to predefined logical files, there are a number of predefined SQL views over the cross-reference files (see the redbook DB2/400 Advanced Database Functions (GG24-4249)).

When you start using DB2's cross-reference files you will soon notice that many fields support null and, in fact, many records contain null values in one or more of these fields. Also, some fields are defined as variable length character fields. You should be familiar with "VARCHAR" fields and fields that support null before using these files.

RPG Tip: On all the RPG compiler commands, you can specify CVTOPT(*VARCHAR) to have variable length character fields declared in the program as fixed-length fields and ALWNULL(*YES) to avoid data-mapping errors when records with null values are retrieved.

Note, the cross-references are read-only. The cross-reference files are all defined with the allow write, allow update, and the allow delete attributes all set to *NO. In addition, since the files are always held in the open state by system jobs, you cannot change the attributes.

-----------------------------------
About the author: Ron Turull is editor of Inside Version 5. He has more than 20 years' experience programming for and managing AS/400-iSeries systems.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts