Bird
0
0

Which of the following is the correct syntax to acquire a session-level advisory lock with key 12345?

easy📝 Syntax Q12 of 15
PostgreSQL - Transactions and Concurrency
Which of the following is the correct syntax to acquire a session-level advisory lock with key 12345?
ASELECT pg_advisory_lock(12345);
BLOCK TABLE pg_advisory_lock(12345);
CSELECT acquire_lock(12345);
DBEGIN LOCK 12345;
Step-by-Step Solution
Solution:
  1. Step 1: Recall advisory lock syntax

    PostgreSQL uses the function pg_advisory_lock(key) to acquire a session-level advisory lock.
  2. Step 2: Evaluate options

    SELECT pg_advisory_lock(12345); is the correct function call. The other options use invalid syntax or non-existent functions.
  3. Final Answer:

    SELECT pg_advisory_lock(12345); -> Option A
  4. Quick Check:

    pg_advisory_lock(key) = correct syntax [OK]
Quick Trick: Use SELECT pg_advisory_lock(key) to lock [OK]
Common Mistakes:
  • Using LOCK TABLE instead of function call
  • Calling non-existent functions like acquire_lock
  • Trying to lock with BEGIN LOCK syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes