Defines the key structure of an indexed file.
The key structure is used to rebuild the index of an indexed file when the original index is missing or corrupt.
When converting non-indexed files to indexed files, this option is required to specify the key information for the new output
file.
You can also use this option to
- Replace the key structure of an existing indexed file with an alternative structure
- Convert one indexed file to another with a different key structure.
- Add a new key to an indexed file or remove an existing key without having to rebuild to a new file
Each key is defined by its starting character position within the record (the first character position in a record is 1) and
its length in characters. The starting position and length must be separated by a plus sign (+) or the letter L.
The definition of one key is separated from the definition of the next key by a colon (:).
Each key can be defined as a number of parts (split key), each part being separated by a comma (,).
Alternate keys (those other than the first defined) can be terminated by the parameter
d, indicating WITH DUPLICATES.
You can use the
s parameter to specify a sparse key. The
s parameter must be followed by the sparse character itself. If the sparse character is non-printable, or a lower or upper
case 'd', the
s parameter must be followed by
dvalue, where
value is the decimal value of the sparse character.
Different key compression values can be specified for each key by using the
c parameter, indicating compression. The
c parameter must be followed by a key compression value between 0 and 7.
You can add or remove a key without having to rebuild to a new file or specify all the keys again. To add a key you use the
a parameter; to remove a key you use the
r parameter. You can only add or remove one key at a time, and you can only rebuild in place. You cannot use any other functions
when you are adding or removing a key
Examples
- This example defines a single key, starting at character position 1 and 20 characters in length.
- This example defines three keys. The first key, the primary key, starts at character position 5 and is 5 characters in length;
the second key, an alternate key allowing duplicates, starts at character position 20 and is 1 character in length; the third
key, a split alternate key, has two parts, the first starting at character position 40 and 2 characters in length and the
second starting at character position 43 and 10 characters in length.
Windows:
/k:5+5:20+1d:40+2,43+10
UNIX:
-k:5+5:20+1d:40+2,43+10
- This example defines two keys. The first key, the primary key, starts at character position 1 and is 5 characters in length;
the second key, an alternate, sparse key allowing duplicates, starts at character position 20 and is 10 characters in length,
the sparse character is Z.
- This example defines two keys. The first key, the primary key, starts at character position 1 and is 5 characters in length.
The second key, an alternate, sparse key allowing duplicates, starts at character position 20 and is 10 characters in length;
the sparse character is the null character.
Windows:
/k:1+5:20+10dsh0
- This example defines two keys. The first key, the primary, starts at character position 1 and is 10 characters in length.
The second key, an alternate compressed key allowing duplicates, starts at character position 11 and is 20 characters in length.
The types of key compression being used are compression of duplicates (1) and compression of leading characters (2).
Windows:
/k:1+10:11+20dc3
- This example adds a new key which allows duplicates. The key starts at character position 1 and is 3 characters in length.
- This example removes the key that starts at character position 10 and is 5 characters in length.
- This example shows how to correctly rebuild the index of an index file when the original index is missing. Use the
s parameter to select an idxformat 4 index.
Note: When the index is missing you should specify the key information exactly as the original key specification for idxformat 4
files, as the data file contains control information related to keys which allow duplicates. If the new key information does
not exactly match, it can result in file corruptions or loss of data. We recommend you use the
f parameter to validate the rebuild once the new key has been created.
Windows:
rebuild infile.dat, outfile.dat /k:1+5:6:10d /s:MF4
UNIX:
rebuild infile.dat, outfile.dat -k:1+5:6:10d -s:MF4