Why do DML statements lock out DDL commands? Let's suppose that you have a DML statement like the following:
UPDATE my_table SET column_X = 10;
Before this statement completes, it would be nice to know that someone doesn't drop MY_TABLE or modify COLUMN_X until the UPDATE statement is finished. The UPDATE statement places a lock barring DDL statements from taking place on the object. Once the UPDATE statement is complete, the lock is released.
The reason you are able to retry your operation and have it succeed is that you ran into a time when no DML statements were being issued against the database object you are interested in. Sometimes the wait will be seconds, and other times the wait will be hours. If you cannot wait, then you have to identify which sessions have locked this object, use the V$LOCKED_OBJECT view, and kill those sessions. Keep in mind that killing these sessions may cause some pain to your end users.
Dig Deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.