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.
Scenario: A DBA needs to grant access to a specific table in DB2 to a new user while ensuring the least privilege principle. How should they approach this task?
- Grant SELECT permission on the specific table to the new user.
- Grant ALL privileges on the specific table to the new user.
- Grant INSERT, UPDATE, and DELETE privileges on the specific table to the new user.
- Grant EXECUTE privilege on the specific table to the new user.
The correct option is to grant SELECT permission on the specific table to the new user. This adheres to the least privilege principle, ensuring that the user only has the necessary access required for their tasks without granting unnecessary privileges. Granting ALL privileges or excessive permissions increases the risk of unintended data manipulation or security breaches.
Which type of subquery returns a single value and can be used within expressions or conditions in SQL statements?
- Correlated subquery
- Derived subquery
- Nested subquery
- Scalar subquery
A scalar subquery in DB2 returns a single value and can be used within expressions or conditions in SQL statements. This makes scalar subqueries versatile and commonly used in various scenarios.