I’m attempting to add a nullable column to a frequently used table in an Oracle 10 OLTP database while the application is running and busy. Adding a nullable column is only a data dictionary change and therefore any table lock is only held for a short period of time (which can be handled by the system).
The problem is that my ALTER TABLE often fails with this:
ORA-00054: resource busy and acquire with NOWAIT specified
My current approach is to bludgen the change in by running it until there happens to be no locks on the table. This means I can’t run such a script in SQL*Plus in full, but need to copy and paste each statement and make sure it works.
Is there a better way?
How about a brute force approach? Put it in an infinite loop and exit it when done. Pseudocode(haven’t checked it):