👁 0
Q: What is RECOVER utility?
Answer:
RECOVER restores data from backup/logs. RECOVER TABLESPACE db.ts. Options: TOCOPY, TORBA, TOLOGPOINT. Image copy is backup. RECOVER applies logs to copy. Essential for disaster recovery.
👁 0
Q: How to create image copy?
Answer:
COPY utility creates backup. COPY TABLESPACE db.ts. FULL or INCREMENTAL. SHRLEVEL REFERENCE or CHANGE. Store in GDG for versions. Regular copies essential for recovery. COPYTOCOPY duplicates copies.
👁 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.
👁 0
Q: How to handle large objects (LOB)?
Answer:
BLOB/CLOB/DBCLOB for large data. Stored in auxiliary tablespace. Use LOB locators for efficiency. FETCH with INTO :lobvar. INSERT with CLOB(text). LOG NO for LOB tablespace optional.
👁 0
Q: What is tablespace?
Answer:
Tablespace is storage container for tables. CREATE TABLESPACE name IN database USING STOGROUP. Contains one or more tables. Segmented/universal tablespace types. Management at tablespace level (REORG, COPY, RECOVER).
👁 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).
👁 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.
👁 0
Q: Explain DB2 locking
Answer:
DB2 locks at row, page, table, tablespace level. X (Exclusive) for writes, S (Share) for reads. IX/IS for intent. Lock escalation moves to higher level. LOCK TABLE statement forces mode. Timeout if wait too long.
👁 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.
👁 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.
👁 0
Q: Explain LOAD utility
Answer:
LOAD inserts large data volumes. LOAD DATA INTO TABLE name. Options: REPLACE, RESUME, LOG NO. Input is SYSREC dataset. LOAD faster than INSERT. Puts tablespace in COPY PENDING after LOG NO.
👁 0
Q: Explain storage group
Answer:
Storage group defines volumes for data. CREATE STOGROUP name VOLUMES(vol1, vol2). Tablespaces assigned to stogroups. DB2 manages space within. PRIQTY/SECQTY control allocation. Foundation of storage management.
👁 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.
👁 0
Q: What is LINEAR dataset?
Answer:
LINEAR VSAM is byte-addressable. No record structure. Used by DB2 tablespaces, system software. DEFINE CLUSTER LINEAR. Accessed via DIV (Data-in-Virtual) or memory mapping.