Skip to content

1Z0-909 OCP MySQL 8.0 Database Developer Practice Questions

Prepare for 1Z0-909 with more than an answer.

200 questions in the full set20 sample questionsUpdated Jan 23, 2026
Level
Professional
Valid for
Lifetime (does not expire)
Domains covered on the exam 7
  1. Connectors and APIs
  2. Data-driven Applications
  3. MySQL Schema Objects and Data
  4. Transactions
  5. Query Optimization
  6. MySQL Stored Programs
  7. JSON and Document Store
  1. 1

    You are analyzing a query's performance using EXPLAIN. The Extra column for a joined table shows Using where; Using index. What does this indicate about the query's execution for that table?

    Show answer details

    Correct answer: D

    Using index means the query is performing an index scan. Using where means that after fetching the rows via the index, the storage engine still needs to apply a WHERE clause filter to them because the index couldn't resolve all conditions. This is different from a covering index (Using index alone), where the index contains all necessary data and no table access is needed. It's a reasonably efficient access method, but it's not a covering index.

  2. 2

    A developer needs to store international product descriptions. The descriptions can contain a wide variety of characters from different languages, including emojis. Which character set and column type combination is most appropriate for this description column?

    Show answer details

    Correct answer: C

    utf8mb4 is the recommended character set for storing Unicode data in MySQL 8.0. It supports the full Unicode standard, including 4-byte characters like emojis. The older utf8 (now an alias for utf8mb3) only supports up to 3-byte characters and cannot store emojis. The TEXT type is appropriate for storing long description strings that may exceed the length limits of VARCHAR.

  3. 3

    What is the primary purpose of using a SAVEPOINT within a database transaction?

    Show answer details

    Correct answer: B

    A SAVEPOINT creates a named marker within the current transaction. This allows you to use ROLLBACK TO SAVEPOINT savepoint_name to undo all changes made since that savepoint was set, without aborting the entire transaction. This is useful for complex operations where you might want to retry a sub-task without losing all the work done earlier in the transaction.

  4. 4

    A stored function is created to calculate a customer's lifetime value based on their orders. This calculation is complex and resource-intensive. To allow the query optimizer to better cache results from this function, how should it be declared?

    Show answer details

    Correct answer: A

    A function should be declared as DETERMINISTIC if it always produces the same result for the same input parameters. This is a hint to the optimizer. If a function is deterministic, a call with a given set of arguments can be replaced with a constant value if it's called multiple times within a single query. A customer lifetime value function that only queries historical data is deterministic. Declaring it as such can lead to performance improvements.

  5. 5

    True or False: A composite index on columns (A, B) can be effectively used by the query optimizer to satisfy a WHERE clause condition of B = 5.

    Show answer details

    Correct answer: B

    This statement is false. For a composite (multi-column) index, the query optimizer can only use the index if the WHERE clause includes a condition on the left-most prefix of the index columns. For an index on (A, B), the optimizer can use it for conditions on A or on A AND B. It cannot use the index to search for conditions on B alone.

  6. 6

    A financial services application is experiencing deadlocks during high-concurrency periods. The problematic transaction involves updating a user's balance and inserting a record into a transaction log table. The database uses the default REPEATABLE READ isolation level. Analysis reveals that two concurrent transactions often attempt to lock the same range of rows in the transaction log table, which is indexed by transaction_date. Which strategy is most effective at resolving these deadlocks while maintaining data consistency?

    Show answer details

    Correct answer: A

    Changing the isolation level to READ COMMITTED for these specific transactions is the best solution. REPEATABLE READ uses gap locks, which can lock the space between index records, leading to a higher chance of deadlocks when inserting into a sequentially indexed column. READ COMMITTED does not use gap locks for ordinary statements, which significantly reduces the likelihood of this type of deadlock. Switching to SERIALIZABLE would worsen the problem by increasing locking. Using LOCK TABLES is too coarse and would serialize access, killing concurrency. Retrying transactions is a valid strategy but doesn't solve the root cause of the frequent deadlocks.

  7. 7

    A developer is building a feature to store user preferences as JSON objects in a user_profiles table. The application needs to update a specific nested attribute (theme.color) and add a new attribute (notifications.enabled) in a single atomic operation. The existing JSON is: {"theme": {"color": "dark"}, "font_size": 14}. Which MySQL function should be used to achieve this?

    Show answer details

    Correct answer: B

    JSON_MERGE_PATCH is the correct function. It follows RFC 7396 semantics, where it recursively merges JSON documents. It updates existing key values and adds new key-value pairs. In this case, it would update theme.color and add notifications.enabled. JSON_SET can update existing values and add new ones, but requires specifying each path and value pair individually, making it less concise for merging objects. JSON_REPLACE only updates existing values and does not add new ones. JSON_MERGE_PRESERVE would create an array if keys conflict, which is not the desired behavior here.

  8. 8

    A data analyst needs to generate a report showing the total sales for each product category, but only for categories with total sales exceeding $10,000. Which of the following query structures is correct?

    erDiagram PRODUCTS ||--o{ ORDER_ITEMS : contains CATEGORIES ||--o{ PRODUCTS : belongs to CATEGORIES { int category_id PK string category_name } PRODUCTS { int product_id PK int category_id FK string product_name decimal price } ORDER_ITEMS { int item_id PK int product_id FK int quantity }

    Show answer details

    Correct answer: B

    The HAVING clause is used to filter groups after aggregation has been performed, whereas the WHERE clause filters rows before aggregation. To filter based on the result of an aggregate function like SUM(), you must use HAVING. The alias total_sales cannot be used in the WHERE clause of the same query level where it is defined.

  9. 9

    You are tasked with optimizing a slow query that retrieves user information. The EXPLAIN output shows that a full table scan is performed on the users table despite an index existing on the email column. The query is: SELECT user_id, name FROM users WHERE YEAR(created_at) = 2023 AND SUBSTRING(email, INSTR(email, '@') + 1) = 'example.com';. What is the primary reason the index on email is not being used?

    Show answer details

    Correct answer: C

    Applying a function like SUBSTRING() or INSTR() to an indexed column in the WHERE clause prevents the MySQL optimizer from using the index on that column. This makes the predicate non-SARGable (Search-Argument-able). To make the query use the index, the WHERE clause should be rewritten to compare the column directly, for example, WHERE email LIKE '%@example.com'. Note that even with LIKE, a leading wildcard (%) can also prevent index usage, but the function application is the definite cause here.

  10. 10

    A developer needs to create a stored procedure that accepts an employee ID and returns their department name and manager's name. Which parameter modes should be used for the department name and manager's name? (Select TWO)

    Show answer details

    Correct answer: B, E

    The OUT parameter mode is used for parameters that the procedure will set and return to the caller. Since the procedure needs to return the department name and manager's name, these should be OUT parameters.

    While using OUT parameters is one way to return values, a common and often preferred method for returning tabular data (even a single row with multiple columns) is to have the stored procedure execute a SELECT statement. This produces a result set that the calling application can then process.

Create an account to continue.