8/27/09 How to find the primary key of a file created using DDS (rather than SQL)

Primary keys are called Unique keys in iSeries DDS. The Unique key can be held to two places, on the physical file itself or on a logical file based over that physical file.

To check the physical file, on a command line use the Display File Description command over the physical file; e.g. DSPFD library/file. Page down the displayed information looking for "Access Path Description." If the Access Path is shown as "Arrival" then the physical file is non-keyed and the records are stored by Relative Record Number (row number) sequence. If the Access Path is keyed then the file is keyed, but the key will only be a primary key if the "Unique key values required’ value is showing "Yes." The key fields themselves will be listed on the lines just below this entry.

To check whether there is a logical file with a Unique key use this two step process: First, find the names of all the logical files based over the physical file by using the Display Data Base Relations command, eg DSPDBR library/file. Second use the Display File Description command (DSPFD) for each logical file, as described above, checking the Access Path information as previously described.

Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2009, Vision Solutions, Inc. All rights reserved. Vision Solutions develops and sells iSeries high availability and AIX replication and clustering solutions. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

No comments: