Q

"Resource busy" error when truncating table

I am inserting records into a sample table at the same time that I'm giving the TRUNCATE TABLE command in another session. I got the "resource busy" error, so I killed the session. But I got the same error. How can I truncate the table?

I am inserting records into a sample table at the same time that I'm giving the TRUNCATE TABLE command in another session. I got the "resource busy" error, so I killed the session. But I got the same error. How can I truncate the table?
The TRUNCATE TABLE command is a Data Definition Language (DDL) command, where as the INSERT, UPDATE and DELETE statements are Data Manipulation Language (DML) commands. DML commands only need a lock on the affected row. DDL commands need a lock on the entire table. If a DML command is unable to obtain a lock due to another transaction, it will wait for that lock to be released. If a DDL command is unable to obtain a lock, that DDL command is not willing to wait for the lock to be released, therefore you get the dreaded "resource busy" error message. In your case, you have three options. One, wait for the transactions holding the lock to finish and then issue your TRUNCATE TABLE command. Two, use the DELETE statement to remove all rows of data from the table. Three, kill the session(s) holding the lock and then issue the TRUNCATE command.
This was first published in January 2006

Dig deeper on Oracle database backup and recovery

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close