How can you optimize performance when using views in DB2?

  • Use dynamic views
  • Use indexed views
  • Use materialized views
  • Use static views
Indexed views in DB2 can significantly improve performance by precomputing and storing the results of the view in the form of an index. This allows for faster data retrieval, especially for complex queries involving joins and aggregations. Materialized views can also be used for performance optimization, but they store the entire result set of the view in a physical table, which might incur overhead for maintenance and storage. 

What is the role of roles in DB2 security?

  • Control user access rights
  • Define access privileges
  • Enforce encryption on data
  • Facilitate group-based permissions
Roles in DB2 security serve to facilitate group-based permissions, allowing administrators to assign sets of privileges to groups of users, simplifying access management and enhancing security. 

DB2 manages deadlock situations by employing ________.

  • Locks
  • Rollbacks
  • Timestamps
  • Transactions
DB2 manages deadlock situations primarily by using locks. Locking ensures that only one transaction can access a resource at a time, thereby preventing conflicting updates that could lead to deadlocks. Transactions, rollbacks, and timestamps are related concepts but are not the primary mechanism for managing deadlocks in DB2. 

Can a cursor in DB2 be used to traverse a result set in reverse order? If so, how?

  • No, DB2 cursors can only traverse result sets in forward order
  • Yes, by setting the SCROLL option to REVERSE
  • Yes, by specifying the FETCH FIRST clause
  • Yes, by using the FETCH PRIOR clause
Yes, a cursor in DB2 can be used to traverse a result set in reverse order by using the FETCH PRIOR clause. This clause allows the cursor to move backward through the result set, fetching the previous row relative to the current position. By specifying FETCH PRIOR, developers can implement functionalities such as scrolling through data in reverse chronological order or navigating through the result set in a custom manner. This capability enhances the flexibility and usability of DB2 cursors in various application scenarios. 

Performance tuning in DB2 aims to optimize ________.

  • Database structure
  • Query execution time
  • SQL queries
  • System resources
Performance tuning in DB2 primarily focuses on optimizing the utilization of system resources such as CPU, memory, and disk I/O to improve overall performance. 

How does a stored procedure differ from a regular SQL statement in DB2?

  • Can execute multiple SQL statements sequentially
  • Can't contain control-flow logic
  • Cannot accept parameters
  • Executes only a single SQL statement
Stored procedures in DB2 can execute multiple SQL statements sequentially, allowing for more complex operations compared to regular SQL statements. 

How does DB2 handle password management for user accounts?

  • Defines table structures
  • Enforces password complexity rules
  • Executes SQL queries
  • Manages database backups
DB2 handles password management for user accounts by enforcing password complexity rules. It allows database administrators to set policies specifying minimum password length, character requirements (such as requiring a combination of letters, numbers, and special characters), and expiration intervals. These measures enhance security by making it harder for unauthorized users to guess or crack passwords, thereby reducing the risk of unauthorized access to the database. Password management is an essential aspect of database security, and DB2 provides features to ensure robust password protection. 

When would you use the IMPORT utility in DB2?

  • Backing up data
  • Exporting data
  • Extracting data from an external file
  • Loading data efficiently
The IMPORT utility in DB2 is used when you need to extract data from an external file and load it into DB2 tables. It provides a convenient way to import data into the database from various external sources, such as flat files or other database systems. This utility helps streamline the data loading process, ensuring data consistency and integrity. 

What factors should be considered when determining the columns to include in an index?

  • Data Distribution, Data Length, and Query Complexity
  • Data Types, Column Order, and Nullability
  • Primary Key Status, Foreign Key References, and Unique Constraints
  • Selectivity, Cardinality, and Query Patterns
When deciding which columns to include in an index in DB2, several factors must be considered. These include selectivity (the uniqueness of values), cardinality (the number of distinct values), and query patterns (frequently used queries). By understanding these factors, you can design indexes that optimize query performance by efficiently retrieving data based on the specific needs of the application. 

________ mechanisms in DB2 help to detect and resolve data integrity violations.

  • Isolation Levels
  • Locking
  • Recovery
  • Validation
Validation mechanisms in DB2, such as check constraints and unique constraints, help detect and prevent data integrity violations during data modification operations.