0
0
MySQLquery~10 mins

Lock types (shared, exclusive) in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to acquire a shared lock on the table.

MySQL
LOCK TABLES my_table [1];
Drag options to blanks, or click blank then click option'
AWRITE
BEXCLUSIVE
CREAD
DSHARED
Attempts:
3 left
💡 Hint
Common Mistakes
Using WRITE instead of READ for shared locks.
Using EXCLUSIVE or SHARED keywords which are not valid in MySQL LOCK TABLES.
2fill in blank
medium

Complete the code to acquire an exclusive lock on the table.

MySQL
LOCK TABLES my_table [1];
Drag options to blanks, or click blank then click option'
AREAD
BWRITE
CSHARED
DEXCLUSIVE
Attempts:
3 left
💡 Hint
Common Mistakes
Using READ instead of WRITE for exclusive locks.
Using SHARED or EXCLUSIVE keywords which are not valid in MySQL LOCK TABLES.
3fill in blank
hard

Fix the error in the code to properly release all locks.

MySQL
[1];
Drag options to blanks, or click blank then click option'
AUNLOCK TABLES
BRELEASE LOCKS
CCOMMIT
DROLLBACK
Attempts:
3 left
💡 Hint
Common Mistakes
Using RELEASE LOCKS which is not a valid MySQL command.
Using COMMIT or ROLLBACK which do not release table locks.
4fill in blank
hard

Fill both blanks to lock the table for reading and then unlock it.

MySQL
LOCK TABLES my_table [1];
-- do some reading
[2];
Drag options to blanks, or click blank then click option'
AREAD
BUNLOCK TABLES
CWRITE
DCOMMIT
Attempts:
3 left
💡 Hint
Common Mistakes
Using WRITE instead of READ for shared lock.
Using COMMIT instead of UNLOCK TABLES to release locks.
5fill in blank
hard

Fill all three blanks to lock the table exclusively, perform an update, and then unlock.

MySQL
LOCK TABLES my_table [1];
UPDATE my_table SET col = 1 WHERE id = 5;
[2];
Drag options to blanks, or click blank then click option'
AREAD
BUNLOCK TABLES
CWRITE
DCOMMIT
Attempts:
3 left
💡 Hint
Common Mistakes
Using READ lock when updating data.
Using COMMIT instead of UNLOCK TABLES to release locks.