Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8777497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:17:32+00:00 2026-06-13T19:17:32+00:00

Is it possible to lock the table restricting reads from other sessions? I would

  • 0

Is it possible to lock the table restricting reads from other sessions? I would more appreciate suggestions like “you can workaround it with …” than “Why do you need that?”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:17:33+00:00Added an answer on June 13, 2026 at 7:17 pm

    At least you acknowledge this is a odd request.

    There are some things you could do to implement this. All of them require some redirection, which means the table must be owned by a separate schema, not the one users connect with. This is because Oracle does not have a mechanism for blocking reads, and a schema owner always has access to their tables; all we can do is deny other users access to our tables.

    One option is to use a view. Most of the time it points to your table.

    create or replace view public_user.your_table 
        as select * from private_user.your_table;
    

    But when you want to deny access you switch it to a different, empty table (which obviously must have the same projection as YOUR_TABLE).

    create or replace view public_user.your_table 
        as select * from private_user.empty_table;
    

    Then when you’ve finished you can run the first statement again.

    This approach is relatively straightforward but requires issuing DDL. This means the account working on YOUR_TABLE also must have rights on the PUBLIC_USER.YOUR_TABLE. Also, issuing DDL will invalidate objects which have a dependency on the table (view).

    So here is an alternative approach.

    create table lock_table (col1 number not null);
    insert into lock_table values (1);
    
    create procedure lock_your_table as
        pragma autonomous_transaction;
    begin
         update lock_table set col1 = 0;
         commit;
    end;
    create procedure unlock_your_table as
        pragma autonomous_transaction;
    begin
         update lock_table set col1 = 1;
         commit;
    end;
    

    We have a different version of the view:

    create or replace view public_user.your_table 
        as select * from private_user.your_table
                    cross join lock_table
            where col1 = 1;
    

    This will return all the rows in YOUR_TABLE or none or them, depending on the value of LOCK_TABLE.COL1. So you withdraw access to the table’s data you run lock_the_table() and to grant it you run unlock_the_table().


    Why does Oracle make it so hard to be this? Because it is confusing to the application users. Oracle has implemented a multi-version concurrency model, which means we can always read tables, regardless of whether anybody else is working with the table. What you want to do flies in the face of that approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I detect if caps lock is toggled in Swing? How
I would like to create a table with scrollable data. I have to freeze
Is it possible to do an explicit shared lock on a table in SQL
Is it possible to determine what a lock type is like whether read or
is it possible to lock selected columns in a mysql table, example table1 with
I would like get 3 random stamps, but each from different country. This query
Possible Duplicate: How can I lock the first row and first column of a
Is it possible to lock the aspect ratio of a JFrame in Java Swing?
Possible Duplicates: Why is lock(this) {...} bad? In C# it is common to use
Is it possible to track the accelerometer value while under the lock screen? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.