IBM DB2 Interview Questions and Answers
Freshers / Beginner level questions & answers
Ques 1. What is IBM DB2?
IBM DB2 is a family of data management products, including database servers, developed by IBM.
Ques 2. What is a stored procedure in DB2?
A stored procedure is a set of SQL and procedural statements that are stored on the database server and can be invoked by a client application or another stored procedure.
Ques 3. Explain the purpose of the COMMIT statement in DB2.
The COMMIT statement in DB2 is used to save all the changes made during the current transaction to the database.
Ques 4. What is a foreign key in DB2?
A foreign key is a column or set of columns in a table that refers to the primary key of another table. It establishes a link between the two tables.
Ques 5. What is a trigger in DB2?
A trigger is a set of SQL statements that are automatically executed, or 'triggered,' in response to a specified event on a particular table or view.
Intermediate / 1 to 5 years experienced level questions & answers
Ques 6. Explain the difference between DB2 and other relational databases.
DB2 is known for its advanced features like pureXML, Time Travel Query, and deep compression, setting it apart from other relational databases.
Ques 7. What is a clustered index in DB2?
A clustered index determines the physical order of data in a table. In DB2, it is implemented using the CLUSTERED keyword during table creation.
Ques 8. What is the difference between a primary key and a unique key in DB2?
Both primary and unique keys enforce the uniqueness of values, but a table can have only one primary key, while it can have multiple unique keys.
Ques 9. What is a cursor in DB2?
A cursor is a database object that allows for both fetching and updating rows from a result set one at a time.
Ques 10. Explain the purpose of the RUNSTATS command in DB2.
The RUNSTATS command is used to collect statistics about the data in tables and indexes, helping the query optimizer to generate efficient query plans.
Ques 11. Explain the ACID properties in the context of DB2.
ACID stands for Atomicity, Consistency, Isolation, and Durability. These properties ensure the reliability of database transactions.
Ques 12. What is a buffer pool in DB2?
A buffer pool is a memory area used to cache table and index data to reduce the I/O operations and improve query performance.
Ques 13. What is the purpose of the LOAD utility in DB2?
The LOAD utility is used to efficiently load large amounts of data into DB2 tables. It is faster than using SQL INSERT statements for bulk data loading.
Ques 14. Explain the difference between a view and a materialized query table (MQT) in DB2.
A view is a virtual table based on the result of a SELECT query, while an MQT is a physical table that stores the result of a query, and its data is updated periodically.
Ques 15. What is a DB2 package?
A DB2 package is a compiled set of SQL statements and procedures stored in the database. It can be executed by database applications.
Ques 16. Explain the purpose of the REORG utility in DB2.
The REORG utility is used to reorganize the physical storage of tables and indexes, optimizing space usage and improving query performance.
Ques 17. What is the purpose of the RUNTIMESTATS option in DB2?
The RUNTIMESTATS option is used to collect runtime statistics for SQL statements, providing information about resource usage during query execution.
Ques 18. Explain the role of the db2ckpwd utility in DB2.
The db2ckpwd utility checks the strength of user passwords in DB2, helping to enforce security policies and prevent weak passwords.
Ques 19. What is a correlated subquery in DB2?
A correlated subquery is a subquery that refers to columns from the outer query. It is executed once for each row processed by the outer query.
Ques 20. Explain the purpose of the EXPORT and IMPORT utilities in DB2.
The EXPORT utility is used to export data from DB2 tables, while the IMPORT utility is used to import data into DB2 tables. They are often used for data migration and backups.
Ques 21. What is a package bind in DB2?
A package bind is the process of associating a package, which contains the compiled form of SQL statements, with a database. It is a crucial step in executing SQL statements.
Ques 22. Explain the purpose of the LOAD RESUME option in the LOAD utility.
The LOAD RESUME option allows the loading of data to resume from the point of failure in case of a previous load failure, reducing the need to reload all data.
Ques 23. What is the purpose of the db2move command in DB2?
The db2move command is used for copying or moving data between databases. It is particularly useful for exporting and importing data in a structured manner.
Ques 24. Explain the concept of table space in DB2.
A table space is a container for database objects such as tables, indexes, and long field columns. It provides a logical grouping of related objects for storage management.
Ques 25. What is a correlated scalar subquery in DB2?
A correlated scalar subquery is a subquery that returns a single value and is evaluated once for each row processed by the outer query, using values from that row.
Ques 26. Explain the purpose of the db2pd command in DB2.
The db2pd command is used to display information about various aspects of the DB2 instance, such as memory usage, locks, and active applications.
Ques 27. Explain the purpose of the REBIND command in DB2.
The REBIND command is used to rebind packages in DB2, refreshing the access plan and optimizing the SQL statements after changes to the database or its statistics.
Ques 28. What is the purpose of the db2exfmt command in DB2?
The db2exfmt command is used to format the output of the EXPLAIN statement, providing a more readable and understandable representation of the access plan.
Ques 29. Explain the purpose of the db2look command in DB2.
The db2look command is used to generate SQL statements that can recreate the structure and data of a database, including tables, indexes, and constraints.
Experienced / Expert level questions & answers
Ques 30. How does isolation level affect database transactions in DB2?
Isolation level determines the degree to which one transaction must be isolated from resource changes made by other transactions.
Ques 31. What is the purpose of the EXPLAIN statement in DB2?
The EXPLAIN statement is used to analyze and optimize SQL queries by providing information about the access path chosen by the DB2 optimizer.
Ques 32. How does DB2 handle concurrency control in a multi-user environment?
DB2 uses various concurrency control mechanisms, including locks and isolation levels, to ensure that transactions execute without interference from other transactions.
Ques 33. How can you improve the performance of a DB2 query?
Performance can be improved by creating indexes, optimizing SQL queries, updating statistics, and using proper join and filter conditions.
Ques 34. What is a DB2 index and how does it improve query performance?
An index is a data structure that provides a quick and efficient way to look up and access data in a table. It improves query performance by reducing the number of rows that need to be scanned.
Ques 35. Explain the purpose of the db2diag.log file in DB2.
The db2diag.log file contains diagnostic information about the database manager and its associated processes. It is used for troubleshooting and monitoring.
Ques 36. How can you monitor and optimize locking in DB2?
Locking can be monitored using tools like db2pd and improved by using proper isolation levels, avoiding long-running transactions, and optimizing SQL queries.
Ques 37. What is a data partitioning feature in DB2?
Data partitioning is a feature in DB2 that allows tables and indexes to be divided into smaller, more manageable pieces, improving query performance and parallelism.
Ques 38. What is the purpose of the db2dart utility in DB2?
The db2dart utility is used for database analysis and recovery. It can be used to check the consistency of database objects and repair certain types of corruption.
Ques 39. How can you monitor and manage database performance in DB2?
Database performance can be monitored using tools like db2top and db2mon. Performance can be managed by optimizing SQL queries, updating statistics, and configuring buffer pools.
Ques 40. What is the purpose of the db2relocatedb command in DB2?
The db2relocatedb command is used to move a database from one directory path to another. It helps in relocating databases without requiring a full backup and restore.
Most helpful rated by users: