z/OS concepts
Previous topic | Next topic | Contents | Glossary | Contact z/OS | PDF

What is VSAM?

z/OS concepts

The term Virtual Storage Access Method (VSAM) applies to both a data set type and the access method used to manage various user data types.

As an access method, VSAM provides much more complex functions than other disk access methods. VSAM keeps disk records in a unique format that is not understandable by other access methods.

VSAM is used primarily for applications. It is not used for source programs, JCL, or executable modules. VSAM files cannot be routinely displayed or edited with ISPF.

You can use VSAM to organize records into four types of data sets: key-sequenced, entry-sequenced, linear, or relative record. The primary difference among these types of data sets is the way their records are stored and accessed.

VSAM data sets are briefly described as follows:
Key Sequence Data Set (KSDS)
This type 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. This provides random access to data. Records are of variable length. IMS™ uses KDSDs.
Entry Sequence Data Set (ESDS)
This form of VSAM keeps records in sequential order. Records can be accessed sequentially. It is used by IMS, DB2®, and z/OS® UNIX®.
Relative Record Data Set (RRDS)
This VSAM format allows retrieval of records by number; record 1, record 2, and so forth. This provides random access and assumes the application program has a way to derive the desired record numbers.
Linear Data Set (LDS)
This type is, 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). DB2 and a number of z/OS system functions use this format heavily, but it is rarely used by application programs.

Several additional methods of accessing data in VSAM are not listed here. Most applications use VSAM for keyed data.

VSAM works with a logical data area known as a control interval (CI) that is diagrammed in Figure 1. The default CI size is 4K bytes, but it can be up to 32K bytes. The CI contains data records, unused space, record descriptor fields (RDFs), and a CI descriptor field.

Figure 1. Simple VSAM control interval

Multiple CIs are placed in a control area (CA). A VSAM data set consists of control areas and index records. One form of index record is the sequence set, which is the lowest-level index pointing to a control interval.

VSAM data is always variable-length and records are automatically blocked in control intervals. The RECFM attributes (F, FB, V, VB, U) do not apply to VSAM, nor does the BLKSIZE attribute. You can use the Access Method Services (AMS) utility to define and delete VSAM structures, such as files and indexes. Defining a VSAM KSDS using AMS shows an example.

RECORDS(1000 500)) -
 KEYS(15 0) -
RECORDSIZE(250 250) -
BUFFERSPACE(25000) ) -

Many details of VSAM processing are not included in this brief description. Most processing is handled transparently by VSAM; the application program merely retrieves, updates, deletes or adds records based on key values.

Copyright IBM Corporation 1990, 2010