Scenario: All accounts created cannot log in to the application, and a table lock is found
Need to query whether the table is locked:
1. Log in to the database where the data is located: log in with an administrator account.
2. Query whether there is a sql for the lock table
SELECT *
FROM V$SESSION T1, V$LOCKED_OBJECT T2
WHERE T1.SID = T2.SESSION_ID;
3. Perform table lock sql:
table-level lock in shared mode (Share)
LOCK TABLE <表名>[,<表名>]... IN SHARE MODE [NOWAIT]
LOCK TABLE TEST_USER IN SHARE MODE
Exclusive table-level lock (Exclusive)
LOCK TABLE <表名>[,<表名>].... IN EXCLUSIVE MODE [NOWAIT]
LOCK TABLE TEST_USER IN EXCLUSIVE MODE
4. View the information of the locked table:
SELECT SESS.SID,
SESS.SERIAL#,
LO.ORACLE_USERNAME,
LO.OS_USER_NAME,
AO.OBJECT_NAME,
LO.LOCKED_MODE
FROM V$LOCKED_OBJECT LO, DBA_OBJECTS AO, V$SESSION SESS
WHERE AO.OBJECT_ID = LO.OBJECT_ID
AND LO.SESSION_ID = SESS.SID;
Query the locked table:
select p.spid,
a.serial#,
c.object_name,
b.session_id,
b.oracle_username,
b.os_user_name
from v$process p, v$session a, v$locked_object b, all_objects c
where p.addr = a.paddr
and a.process = b.process
and c.object_id = b.object_id;
5. View the number of connections currently being used by the database
select count(*) from v$process
6. View the number of connections currently occupied by the user
select a.OSUSER 用户,count(1) 连接数 from v$session a group by OSUSER order by 连接数 desc
7. View the maximum number of connections currently configured by Oracle
select value from v$parameter where name ='processes'
8. Get rid of the lock:
alter system kill session 'sid列,serial#列'
Row lock
Commit the transaction from automatic submission to manual submission. When an operation is performed on a piece of data, before the transaction is committed, any other operation on the piece of data is to read the previous data to prevent dirty reading
Gap lock
In the interval query or modification of the table, the operation is exclusively used, and other operations require the execution of the operation to be completed. Comparison affects performance