The RECID of the _index record represents the primary index of a table is stored in the table (_file) record itself.
To determine which _index record is primary in a table, perform a find by RECID on the _index table.
Example: List the primary indices for all application tables in a database:
FOR EACH _file WHERE _file._file-number > 0 NO-LOCK.
FIND _index OF _file WHERE RECID(_index) = _file._prime-index NO-LOCK NO-ERROR.
IF AVAILABLE _index THEN
DISPLAY _file._file-name _index._index-name.
END.
The above query can be modified to create an input file for IDXBUILD or IDXFIX with only the application schema Primary Indexes:
$ proutil dbname -C idxbuild < index_primes.file
$ proutil dbname -C idxfix < index_primes.file
OUTPUT TO "index_primes.file".
/* Uncoment the relevant section for either IDXBUILD or IDXFIX required menu input */
/*
/* #1 IDXBUILD for a selective primary indexes */
PUT UNFORMATTED
"some" SKIP.
*/
/*
/* #2 IDXFIX Option 3 for a selective primary indexes*/
PUT UNFORMATTED
"3" SKIP
"some" SKIP.
*/
FOR EACH _file WHERE _file._file-number > 0 AND NOT _file-name BEGINS "SYS",
FIRST _index WHERE RECID(_index) = _file._prime-index NO-LOCK:
PUT UNFORMATTED _file-name SKIP _index-name SKIP.
END.
/*
/* #1 IDXBUILD Footer for a selective primary indexes */
PUT UNFORMATTED "!" SKIP.
PUT UNFORMATTED "Y" SKIP.
PUT UNFORMATTED "Y" SKIP.
*/
/*
/* #2 IDXFIX Footer for a selective primary indexes */
PUT UNFORMATTED
"!" SKIP
"Y" SKIP
"Y" SKIP
"Y" SKIP
"all" SKIP
"Y" SKIP.
*/
OUTPUT CLOSE.