I understand that DDL statements in Oracle have an implicit commit before and after the statement, which obviously affects the current transaction.
However, does a DDL statement in any way affect other transactions running against that table (assuming the change is compatible with the DML running against the table)?
For example, if I decide to modify
a varchar2(10)
columnn to varchar2(20)
, or add a new column altogether, or drop an obsolete, no longer used column — are other transactions going to be happy about it, or is there going to be any sort of contention or interruption of running transactions?
Best Answer
This article explains how DDL statements work and how they need exclusive table locks, which plays out nicely when there are transactions running against the table. To summarize:
If the table cannot be locked due to another transaction having a lock on the table
would be thrown. If the DDL manages to acquire the lock, obviously, any other transaction will block at the point where it needs a lock on the table, until the DDL finishes.
Additionally, since 11g, it is possible to enqueue DDL statements in FIFO order with other statements to get a lock on a table:
In older versions of Oracle, it could be a challenge to perform this task on a heavily used table.