VSAM applies to both a data set type and the access method used to manage various user data types.
VSAM data sets are held on direct access storage devices (DASD) auxiliary storage. VSAM divides its data set storage into control areas (CA), which are further divided into control intervals (CI). Control intervals are the unit of data transmission between virtual and auxiliary storage. Each one is of fixed size and, in general, contains a number of records. A KSDS or ESDS can have records that extend over more than one control interval. These are called spanned records.
VSAM is primarily used for applications.
- Key-Sequenced Data Set
- This is the most common use for VSAM
- Each record has one or more key fields and a record can be retrieved (or inserted) by key value.
- To find the physical location of a record in a KSDS, VSAM creates and maintains an index. This relates the key of each record to the record’s relative location in the data set. When you add or delete records, this index is updated accordingly.
- It provides random access of data.
- Starting with releases of DFSMS/MVS 1.4 and later, a data set can be greater than 4GB in size if it is defined as extended format and extended addressability in the storage class
- The KSDS cluster has two components in it:
- Index component
- Data component
- Entry-Sequenced Data Set
- Keeps records in sequential order
- Each record is identified by its Relative Byte Address (RBA)
- Records are held in the order in which they were first loaded into the data set.
- New records added to an ESDS always go after the last record in the data set.
- You cannot delete records or alter their lengths. After a record has been stored in an ESDS, its RBA remains constant.
- When browsing, records are retrieved in the order in which they were added to the data set.
- A standard ESDS (32 bit RBA) cannot contain more than 4 gigabytes (GB) of data. However, there is a different kind of ESDS that supports 64-bit Extended Relative Byte Addresses (XRBAs) and which is therefore not subject to the 4GB limit
- Relative Record Data Set
- RRDS records are identified by their Relative Record Number (RRN). The first record in the data set is RRN 1, the second is RRN 2, and so on.
- Provides random access and assumes the application program has a way to derive the desired record numbers.
- Records in an RRDS can be fixed or variable length records, and the way in which VSAM handles the data depends on whether the data set is a fixed or variable RRDS.
- A fixed RRDS has fixed-length slots predefined to VSAM, into which records are stored. The length of a record on a fixed RRDS is always equal to the size of the slot. VSAM locates records in a fixed RRDS by multiplying the slot size by the RRN (which you supply on the file control request), to calculate the byte offset from the start of the data set.
- A variable RRDS, on the other hand, can accept records of any length up to the maximum for the data set. In a variable RRDS VSAM locates the records by means of an index.
- A fixed RRDS generally offers better performance. A variable RRDS offers greater function.
- With releases of DFSMS/MVS 1.5 and later, a data set can be greater than 4 GB in size if it is defined as extended format and extended addressability in the storage class.
- Linear Data Set
- It’s in effect a byte-stream data set and is the only form of a byte-stream data set in traditional z/OS files (as opposed to z/OS Unix files).
- A number of z/OS system functions use this format heavily, but is rarely used by application programs.
- It is a VSAM data set with a control interval size multiple of 4096 bytes.
- In a sense, a LDS is a non-VSAM file with some of the VSAM facilities, such as the use of IDCAMS and VSAM specific information in the catalog.
- The most common LDS exploiter is DB2
- Like the ESDS and RRDS, an LDS contains a data component only.