The physical organization of VSAM data sets differs considerably from the organizations used by other access methods.
VSAM data sets are held in control intervals (CI) and control areas (CA). The size of the CI and CA is normally determined by the access method, and the way in which they are used is not visible to you.
You can use three types of file organization with VSAM:
VSAM entry-sequenced data sets are equivalent to QSAM sequential files. The order of the records is fixed.
In a VSAM fixed-length RRDS, records are placed in a series of fixed-length slots in storage. Each slot is associated with a relative record number. For example, in a fixed-length RRDS containing 10 slots, the first slot has a relative record number of 1, and the tenth slot has a relative record number of 10.
In a VSAM variable-length RRDS, the records are ordered according to their relative record number. Records are stored and retrieved according to the relative record number that you set.
Throughout this documentation, the term VSAM relative-record data set (or RRDS) is used to mean both relative-record data sets with fixed-length records and with variable-length records, unless they need to be differentiated.
The following table compares the characteristics of the different types of VSAM data sets.
| Characteristic | Entry-sequenced data set (ESDS) | Key-sequenced data set (KSDS) | Relative-record data set (RRDS) |
|---|---|---|---|
| Order of records | Order in which they are written | Collating sequence by key field | Order of relative record number |
| Access | Sequential | By key through an index | By relative record number, which is handled like a key |
| Alternate indexes | Can have one or more alternate indexes, although not supported in COBOL | Can have one or more alternate indexes | Cannot have alternate indexes |
| Relative byte address (RBA) and relative record number (RRN) of a record | RBA cannot change. | RBA can change. | RRN cannot change. |
| Space for adding records | Uses space at the end of the data set | Uses distributed free space for inserting records and changing their lengths in place | For fixed-length RRDS,
uses empty slots in the data set
For variable-length RRDS, uses distributed free space and changes the lengths of added records in place |
| Space from deleting records | You cannot delete a record, but you can reuse its space for a record of the same length. | Space from a deleted or shortened record is automatically reclaimed in a control interval. | Space from a deleted record can be reused. |
| Spanned records | Can have spanned records | Can have spanned records | Cannot have spanned records |
| Reuse as work file | Can be reused unless it has an alternate index, is associated with key ranges, or exceeds 123 extents per volume | Can be reused unless it has an alternate index, is associated with key ranges, or exceeds 123 extents per volume | Can be reused |