Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

locking a table to prevent changes throughout a transaction with DDL - how

User_UAEUZJun 2 2017 — edited Jun 4 2017

Hi all,

I have this script with the following flow

T1) create table newA1 from tableA where some condition;

....

T2) create table newA2 from tableA where some condition;

I need tableA to remain unchanged / there must be no transaction in tableA all the way from before T1 till after T2

=====================

I thought of adding

lock tableA in exclusive mode before T1, but right after the CREATE TABLE DDL at T1, the lock is release due to autocommit nature of the DDL.

-- lock tableA in exclusive modeĀ  (add here)

T1) create table newA1 from tableA where some condition;

-- lock release automatically

-- lock tableA in exclusive mode again

T2) create table newA2 from tableA where some condition;

I would have to manually lock the table again before T2 which kindof leave a time gap (no matter how small it is) for chance/probability for DMLs on tableA .

q1) How do I overcome this problem ? such that tableA remains lock throughout the entire T1 to T2 duration ?

Regards,

Noob

This post has been answered by unknown-3431574 on Jun 2 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 2 2017
Added on Jun 2 2017
20 comments
1,458 views