System Management Lesson 10. Managing Data Concurrency

1. Please give a complete description of the Oracle database lock mechanism.

Lock: It
can prevent multiple sessions from changing the same data at the same time. It
is automatically acquired (rows, blocks, tables) (objects, databases, schemes) at the lowest possible level of the specified statement.
Locking mechanism:
(Provides) Advanced data concurrent processing (capability):

  • Use row-level locks when performing inserts, updates, and deletes
  • The query does not require any locks.
    Automatic queue management. Locks
    are kept until the end of the transaction (using COMMIT or ROLLBACK operations)

2. Why does a transaction acquire a shared table lock at the same time when it acquires an exclusive row lock?

When modifying the database, read the data from the block to the memory, submit it after modification, and write it to the data file by the database writing process.
Prevent users from modifying the table row data while other administrators delete the table.

3. When a lock conflict occurs, how to resolve it, please give the corresponding SQL command.

The first step is to find out the Session ID (session ID)
SQL statement

SELECT sid, serial#, username FROM v$session
    WHERE sid IN (SELECT blocking_session FROM v$session);

v$session Current session
blocking_session Any session that holds a lock The
second step to resolve lock conflicts
ALTER SYSTEM KILL SESSION'SID,SERIAL#' IMMEDIATE;

A. The session holding the lock is submitted or rolled back (released)
B. The session holding the lock is terminated (in emergency)

4. How did the deadlock happen and how to solve it?

Transaction T1 is waiting for T2, and T2 is waiting for T1. The two transactions can never end.
Two or more sessions are waiting for data that has been locked by the other session.

ORA-00060
Deadlock detectd while waiting for resource
solution:
completely automatic, kill one of the transactions

5. The row lock of the Oracle database is essentially a lock on the data block. Is this statement correct?

Wrong The
relational table data is stored line by line in the block, and the row piece is
locked.

6. OCP exam questions:

ABE

TM lock (table-level lock)
TX lock (transactional lock or row-level lock)
lock type:
exclusive lock (exclusive lock, namely X lock) (write lock) Only transaction T is allowed to read and modify data object A, no other transactions In the
shared lock (share lock, S lock) of data object A (read lock) transaction T can read data object A but cannot modify A, other transactions can only add S lock to A, but not S lock

Database lock mechanism
oracle-database various-lock-detailed

Guess you like

Origin blog.csdn.net/hezuijiudexiaobai/article/details/108777826