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 last published in January 2006

Dig Deeper on Oracle database backup and recovery

PRO+

Content

Find more PRO+ content and other member only offers, here.

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.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close