VSAM ⭐ Featured
👁 0

Q: What is the difference between KSDS and ESDS?

Answer:

KSDS (Key Sequenced Data Set):

  • Records accessed by unique key
  • Records stored in key sequence
  • Has both data and index components
  • Supports random and sequential access
  • Can delete and reinsert records
  • Most commonly used VSAM type

ESDS (Entry Sequenced Data Set):

  • Records stored in arrival order
  • Accessed by RBA (Relative Byte Address)
  • No index component
  • Cannot delete records (only mark inactive)
  • Similar to sequential files
  • Good for logs, audit trails

Use KSDS when: You need key-based access, updates, deletes

Use ESDS when: Sequential processing only, append-only data

COBOL ⭐ Featured
👁 0

Q: How does SEARCH ALL differ from SEARCH?

Answer:
SEARCH performs a sequential/linear search from the current index position. SEARCH ALL performs a binary search requiring the table to be sorted (ASCENDING/DESCENDING KEY clause) and indexed. SEARCH ALL is faster for large tables but requires sorted data.
DB2 ⭐ Featured
👁 0

Q: How to handle restrictive states?

Answer:
COPY PENDING needs image copy. CHECK PENDING needs CHECK DATA. REBUILD PENDING needs REBUILD INDEX. REORG PENDING needs REORG. RECOVER PENDING needs RECOVER. Use -DISPLAY DATABASE to see status.
DB2 ⭐ Featured
👁 0

Q: Explain predicate types

Answer:
Stage 1 predicates evaluated by storage engine. Stage 2 evaluated by DB2 (more expensive). Indexable predicates can use index. Non-indexable force scan. Design for stage 1/indexable predicates. EXPLAIN shows predicate staging.
DB2 ⭐ Featured
👁 0

Q: What is index-only access?

Answer:
Index-only access retrieves data from index without table access. All needed columns in index (including by include clause). Best performance. EXPLAIN shows INDEXONLY=Y. Design indexes for common queries.
DB2 ⭐ Featured
👁 0

Q: How to tune DB2 queries?

Answer:
Check EXPLAIN output. Look at: access type (index vs scan), join method, sort operations. Add indexes for predicates. Rewrite with hints. Update statistics. Check for full tablespace scans. Monitor actual execution.
DB2 ⭐ Featured
👁 0

Q: What is XML support in DB2?

Answer:
DB2 stores XML natively. XMLTYPE column. XMLPARSE, XMLSERIALIZE for conversion. XQuery for querying. XMLTABLE extracts relational from XML. XML indexes for performance. Powerful for document storage.
DB2 ⭐ Featured
👁 0

Q: What is OPTIMIZE FOR n ROWS?

Answer:
OPTIMIZE FOR n ROWS hints expected rows. SELECT * FROM t ORDER BY c OPTIMIZE FOR 1 ROW. Influences access path. Low n favors index. High n may favor scan. Use when you know actual row count.
COBOL ⭐ Featured
👁 0

Q: What is ORGANIZATION clause?

Answer:
ORGANIZATION specifies file structure: SEQUENTIAL (default), INDEXED (VSAM KSDS), RELATIVE (RRDS). Determines access methods available. INDEXED requires RECORD KEY. ACCESS MODE can be SEQUENTIAL, RANDOM, or DYNAMIC.
VSAM ⭐ Featured
👁 0

Q: How to define KSDS cluster?

Answer:
IDCAMS DEFINE CLUSTER(NAME(ds.name) INDEXED KEYS(len offset) RECORDSIZE(avg max) SHAREOPTIONS(2 3)) DATA(NAME(ds.data) CYLINDERS(5 1)) INDEX(NAME(ds.index) CYLINDERS(1 1)). Keys required for INDEXED.
VSAM ⭐ Featured
👁 0

Q: What is alternate index?

Answer:
AIX provides secondary access path. DEFINE AIX over base cluster. Different key. DEFINE PATH to access. BLDINDEX populates. UPGRADE option maintains AIX on base updates. Multiple AIX per cluster.
COBOL ⭐ Featured
👁 0

Q: How to handle OCCURS INDEXED tables?

Answer:
Indexed tables use INDEXED BY: 05 TBL OCCURS 10 INDEXED BY IDX. SET IDX TO 1 initializes. SET IDX UP BY 1 increments. SEARCH uses index implicitly. More efficient than subscript-index conversion.
VSAM ⭐ Featured
👁 0

Q: How to delete VSAM cluster?

Answer:
IDCAMS DELETE ds.name CLUSTER. Or DELETE ds.name FILE(ddname) if DD provided. PURGE overrides retention. ERASE clears data. DELETE removes catalog entry and data/index components.
VSAM ⭐ Featured
👁 0

Q: What is RBA?

Answer:
RBA (Relative Byte Address) is byte offset from dataset start. ESDS uses RBA for access. KSDS index points to RBA. Changed by REORG. Use key for KSDS, RBA only when necessary.
VSAM ⭐ Featured
👁 0

Q: What is IMBED option?

Answer:
IMBED places sequence set (lowest index level) in data CA. Reduces I/O for index access. Uses more data space. Obsolete with modern systems - use defaults. May still see in old definitions.
COBOL ⭐ Featured
👁 0

Q: How to define FILE-CONTROL?

Answer:
SELECT file-name ASSIGN TO ddname. ORGANIZATION IS INDEXED. ACCESS MODE IS DYNAMIC. RECORD KEY IS key-field. ALTERNATE RECORD KEY IS alt-key. FILE STATUS IS ws-status. Maps COBOL file to physical dataset.
VSAM ⭐ Featured
👁 0

Q: Explain BUFFERSPACE parameter

Answer:
BUFFERSPACE sets total buffer memory. Alternative to BUFND/BUFNI. BUFFERSPACE(65536) allocates 64K for buffers. System divides between index and data. Simpler than separate settings.
VSAM ⭐ Featured
👁 0

Q: How to improve KSDS performance?

Answer:
Appropriate CISIZE, FREESPACE. Adequate buffers (BUFND/BUFNI). Index in cache if possible. IMBED obsolete. Keep file organized (REORG). Monitor CA/CI splits. Sequential access for bulk.
VSAM ⭐ Featured
👁 0

Q: What is EXAMINE utility?

Answer:
EXAMINE checks VSAM structural integrity. EXAMINE NAME(ds.name) INDEXTEST DATATEST. Finds problems in index, data. Run periodically or when problems suspected. Output shows errors.
JCL ⭐ Featured
👁 0

Q: How to define VSAM in JCL?

Answer:
//DD DD DSN=VSAM.CLUSTER,DISP=SHR for existing. New cluster needs IDCAMS DEFINE CLUSTER. JCL references cluster, not data/index. AMP parameter for VSAM options: AMP=(BUFNI=8,BUFND=4). Cannot create VSAM with JCL alone.
DB2 ⭐ Featured
👁 0

Q: What is RUNSTATS and when to use it?

Answer:
RUNSTATS collects table/index statistics for optimizer. Run after significant data changes (loads, deletes). Updates catalog tables (SYSTABLES, SYSINDEXES). Optimizer uses for access path selection. RUNSTATS TABLESPACE db.ts INDEX(ALL).
DB2 ⭐ Featured
👁 0

Q: How does REORG work?

Answer:
REORG physically reorganizes tablespace or index. Eliminates fragmentation, reclaims space, restores clustering. REORG TABLESPACE db.ts. Options: SHRLEVEL (REFERENCE/CHANGE), LOG (YES/NO). Schedule during low activity. Run RUNSTATS after.
DB2 ⭐ Featured
👁 0

Q: What is DB2 catalog?

Answer:
Catalog tables describe DB2 objects. SYSIBM.SYSTABLES for tables, SYSIBM.SYSCOLUMNS for columns, SYSIBM.SYSINDEXES for indexes. Query catalog for metadata. Read-only except through DDL. Essential for documentation and analysis.
DB2 ⭐ Featured
👁 0

Q: How to handle -904 SQLCODE?

Answer:
-904 is resource unavailable. Tablespace/index in restricted state, stopped, or unavailable. Check display status. May need START DATABASE command. Check for REORG, RECOVER, LOAD running. Wait and retry.
VSAM ⭐ Featured
👁 0

Q: What is IMBEDDED index?

Answer:
IMBEDDED places sequence set in data CA. Reduces I/O for index access. Obsolete - modern systems don't benefit. Use system defaults. May see in old definitions.
VSAM ⭐ Featured
👁 0

Q: What is maximum VSAM key length?

Answer:
Maximum key length is 255 bytes. KEYS(255 offset). Practical limits lower for performance. Index size grows with key. Keep keys reasonably sized.
DB2 ⭐ Featured
👁 0

Q: Explain CREATE INDEX

Answer:
CREATE INDEX creates index on table. CREATE INDEX idx ON table(col1, col2). UNIQUE prevents duplicates. CLUSTER determines physical order. Include columns for index-only access. Drop unused indexes for insert performance.
DB2 ⭐ Featured
👁 0

Q: What is clustered index?

Answer:
Clustered index determines physical row order. Only one per table. Other indexes are secondary. CLUSTER keyword on CREATE INDEX. Good for range queries on cluster key. REORG restores clustering after updates.
DB2 ⭐ Featured
👁 0

Q: What is BETWEEN operator?

Answer:
BETWEEN tests range inclusively. WHERE col BETWEEN 1 AND 100. Equivalent to col >= 1 AND col <= 100. Works with dates, times. Can use NOT BETWEEN for exclusion. Index can be used for BETWEEN.
DB2
👁 0

Q: What is CHECK utility?

Answer:
CHECK validates data integrity. CHECK DATA TABLESPACE db.ts. Finds constraint violations, orphan rows. CHECK INDEX validates index structure. CHECK LOB for LOB issues. Run periodically or after issues.
DB2
👁 0

Q: What is REBIND and when needed?

Answer:
REBIND updates access path without precompile. REBIND PACKAGE after RUNSTATS, index changes. REBIND PLAN for plan-level changes. Can improve or degrade performance - test first. EXPLAIN before/after.
COBOL
👁 0

Q: How to define and use indexes?

Answer:
INDEX defined with OCCURS: 05 WS-TABLE OCCURS 10 INDEXED BY WS-IDX. SET WS-IDX TO 5 sets position. SET WS-IDX UP/DOWN BY 1 changes position. Use SEARCH verb with index. More efficient than subscripts for table access.
DB2
👁 0

Q: Explain access path selection

Answer:
Optimizer chooses access path based on statistics, predicates, indexes. Index scan vs tablespace scan. Join methods: nested loop, merge scan, hybrid. Sort operations. EXPLAIN reveals choice. Tuning influences path.
COBOL
👁 0

Q: How to work with OCCURS indexed tables?

Answer:
Define: 01 WS-TABLE. 05 WS-ENTRY OCCURS 100 INDEXED BY WS-IDX. 10 WS-NAME PIC X(20). 10 WS-VALUE PIC 9(5). Access: MOVE WS-NAME(WS-IDX) TO output. Search: SEARCH WS-ENTRY WHEN WS-NAME(WS-IDX) = 'VALUE' perform action.
COBOL
👁 0

Q: Explain ALTERNATE RECORD KEY

Answer:
ALTERNATE RECORD KEY defines secondary indexes for INDEXED files. SELECT file-name ALTERNATE RECORD KEY IS ALT-KEY WITH DUPLICATES. Allows access by multiple keys. DUPLICATES permits non-unique values. Define path in VSAM cluster.
COBOL
👁 0

Q: How to define table with KEY?

Answer:
For binary search, tables need KEY: 05 WS-TABLE OCCURS 100 ASCENDING KEY WS-CODE INDEXED BY WS-IDX. 10 WS-CODE PIC X(5). 10 WS-DESC PIC X(20). SEARCH ALL requires sorted data per KEY. Multiple keys for complex sorts.
VSAM
👁 0

Q: Explain BUFND and BUFNI

Answer:
BUFND is data buffer count, BUFNI is index buffer count. More buffers improve performance but use memory. JCL AMP='BUFNI=10,BUFND=20'. Default usually 2. Tune based on access pattern.
VSAM
👁 0

Q: Explain UPGRADE attribute

Answer:
UPGRADE keeps AIX synchronized with base cluster. Changes to base automatically update upgraded AIX. Adds overhead to writes. Non-upgrade AIX needs manual BLDINDEX. Use UPGRADE for real-time currency.
COBOL
👁 0

Q: How to define OCCURS ASCENDING?

Answer:
05 TABLE OCCURS 100 ASCENDING KEY IS CODE-FIELD INDEXED BY IDX. 10 CODE-FIELD PIC X(5). 10 DATA-FIELD PIC X(20). ASCENDING means lower values first. Required for SEARCH ALL. DESCENDING also available. Key must be within occurrence.
VSAM
👁 0

Q: How to define ESDS?

Answer:
DEFINE CLUSTER(NAME(ds.name) NONINDEXED RECORDSIZE(avg max)) DATA(NAME(ds.data) CYLINDERS(10 2)). NONINDEXED means ESDS. No KEYS or INDEX components. Access by RBA only.
VSAM
👁 0

Q: Explain DEFINE CLUSTER syntax

Answer:
DEFINE CLUSTER(NAME(ds) ...) DATA(NAME(ds.data) ...) INDEX(NAME(ds.index) ...). CLUSTER level: type, SHAREOPTIONS. DATA level: space, RECORDSIZE. INDEX level: space for KSDS index.
VSAM
👁 0

Q: What is REPLICATE option?

Answer:
REPLICATE duplicates sequence set on each track. Each track has own copy of sequence set index. Reduces contention. Obsolete with modern systems. Uses more space.
JCL
👁 0

Q: What is KEYLEN parameter?

Answer:
KEYLEN specifies key length for new dataset. DCB parameter for VSAM-like. Or VSAM DEFINE CLUSTER KEYS(length offset). Length 1-255. Required for indexed organization. Offset from 0 or 1 depending on context.
JCL
👁 0

Q: What is AMP parameter?

Answer:
AMP specifies VSAM buffer parameters. AMP='BUFNI=8,BUFND=4' for index/data buffers. AMP='AMORG' for VSAM organization. OPTCD for options. Overrides VSAM cluster definitions for this run. Affects performance.
JCL
👁 0

Q: Explain DEFINE PATH for VSAM?

Answer:
PATH provides alternate access to VSAM cluster via alternate index. IDCAMS: DEFINE PATH NAME(path.name) PATHENTRY(aix.name). Reference PATH in JCL, not AIX directly. Allows secondary key access.
DB2
👁 0

Q: What is EXPLAIN and how to use it?

Answer:
EXPLAIN analyzes query access path. EXPLAIN PLAN SET QUERYNO=1 FOR SELECT... Results in PLAN_TABLE. Shows index usage, join method, sort operations. Use for performance tuning. Review ACCESSTYPE, MATCHCOLS, PREFETCH columns.
DB2
👁 0

Q: How to handle -803 SQLCODE?

Answer:
-803 is duplicate key violation. Primary key or unique index constraint. Check SQLERRD(3) for index ID. Solutions: check data, use IGNORE_DUPLICATE, handle in program logic. May indicate data quality issue.
VSAM
👁 0

Q: What is DEFINE ALTERNATEINDEX syntax?

Answer:
DEFINE AIX(NAME(aix.name) RELATE(base.cluster) KEYS(len offset)) DATA(NAME(aix.data)) INDEX(NAME(aix.index)). UNIQUEKEY or NONUNIQUEKEY. UPGRADE to maintain automatically. Must DEFINE PATH and BLDINDEX after.
VSAM
👁 0

Q: How to use BLDINDEX utility?

Answer:
BLDINDEX creates AIX entries from base. IDCAMS BLDINDEX INDATASET(base) OUTDATASET(aix). Reads base cluster, writes AIX. Required after AIX definition. EXTERNALSORT for large datasets.
DB2
👁 0

Q: What is DB2 buffer pool?

Answer:
Buffer pool caches data/index pages in memory. BP0, BP1, etc. Hit ratio critical for performance. GETPAGE vs SYNCIO shows effectiveness. Size appropriately. Virtual buffer pool for each pool. Monitor with statistics.
DB2
👁 0

Q: How to use LIKE for patterns?

Answer:
LIKE matches patterns. % matches zero or more chars. _ matches single char. WHERE name LIKE 'SM%' finds Smith, Smart. ESCAPE clause for literal % or _. Not index friendly unless prefix match (e.g., 'ABC%').