Oracle Database MySQL 5.6 Developer — Question 20

In MYSQL 5.6 you have the table t1:
CREATE TABLE t1 (
id int unsigned NOT NULL PRIMARY key) ENGINE = InnoDB;
There are two connections to the server. They execute in this order:
Connection 1> SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
Connection 1> START TRANSACTION;
Connection 1> SELECT * FROM t1 WHERE id =1;
Connection 2> TRUNCATE TABLE t1;
What happens to the TRUNCATE TABLE command in connection 2?

Answer options

Correct answer: C

Explanation

The correct answer is C because the TRUNCATE TABLE command requires a metadata lock, which cannot be acquired while another transaction is ongoing that has a lock on the table. Options A and B are incorrect as they suggest that the command can proceed immediately or concurrently, which is not the case. Option D is also incorrect because TRUNCATE TABLE does not acquire a table lock but instead a metadata lock.