Errors such as Ora-00054:resource busy and acquire with nowait specified are often present when a database user inserts, updates, deletes data from a table in a database, or increases the primary key of a table or the index of a table.
The main reason is that a transaction is executing (or the transaction has been locked), all of which cause the execution to be unsuccessful.
1. Users with DBA authority to see which locks are in the database
Select T2.username,t2.sid,t2.serial#,t2.logon_time
From V$locked_object t1,v$session T2
where T1.session_id=t2.sid order by T2.logon_time;
Example: TestUser 339 13545 2009-3-5 17:40:05
Know that the locked user TESTUSER,SID for 339,serial# is 13545
2, according to the SID view specific SQL statements, if SQL is not important, you can kill
Select Sql_text from v$session a,v$sqltext_with_newlines b
where DECODE (a.sql_hash_value, 0, Prev_hash_value, sql_hash_value) =b.hash_value
and a.sid=&sid order by piece;
Find out the SQL, such as: begin:id: = sys.dbms_transaction.local_transaction_id; End
3. Kill the transaction
Alter system kill session ' 339,13545 ';
4, so you can execute other transactional SQL statements
If you add a table's primary key:
ALTER TABLE test
Add constraint Pk_test primary key (TEST_NO);
If prompted : Ora-00030:user session ID does not exist
Alter session SET Events ' immediate trace name Flush_cache Level 1 ';
The consequences are unknown
ora-00031:session marked for kill
Some Oracle processes have been killed, the state is set to "killed", but the locked resources are not released for a long time, sometimes there is no way to restart the database. Now provides a way to solve this problem, that is, in Oracle can not kill, at the OS level to kill.
1. The following statement is used to query which objects are locked:
Select object_name,machine,s.sid,s.serial#
From V$locked_object l,dba_objects O, v$session s
where l.object_id = o.object_id and l.session_id=s.sid;
2. The following statement is used to kill a process:
Alter system kill session ' 24,111 '; (24,111 of which are the sid,serial# of the above query)
Note: The above two steps can be performed through the management console of Oracle.
3. If the process state is set to "killed" after killing a process with the above command, but the locked resource is not released for a long time, then the corresponding process (thread) can be killed at the OS level, first executing the following statement to get the process (thread) Number:
Select spid, Osuser, S.program
From V$session s,v$process p
where S.paddr=p.addr and s.sid=24 (24 is the SID above)
4. Kill the process (thread) on the OS:
1) on Unix, execute the command as root :
#kill-9 12345 (that is, the SPID queried in step 3rd)
2) in Windows (also applicable to Unix) to kill threads with Orakill, Orakill is an executable command provided by Oracle with the following syntax:
Orakill SID Thread
which
Sid: Represents the instance name of the process to kill
Thread: Is the number of threads to be killed, that is, the SPID that is queried in step 3rd.
Example: C:>orakill ORCL 12345
Ora-00031:session marked for Kill
Cause:the session specified in an ALTER SYSTEM KILL session command cannot being killed immediately (because it is rolling b Ack or blocked on a network operation), but it had been marked for kill. This means it would be killed as soon as possible after its current uninterruptible operation was done.
Action:no action is required for the session to being killed, but further executions of the ALTER SYSTEM KILL session Comman D on this session could cause the session to be killed sooner.
Kill-9 12345
Ora-00054:resource busy and acquire with nowait specified