user9507446
user9507446

Reputation: 401

Is there any way to prevent table from updating?

As mentioned in the title, is it possible to prevent the data in the table from being updated? I tried using the following trigger

CREATE OR REPLACE TRIGGER block_payment_update
BEFORE UPDATE ON payment  
DECLARE 
e_no_update_allowed EXCEPTION;
BEGIN
    RAISE e_no_update_allowed;
    EXCEPTION WHEN e_no_update_allowed THEN
    dbms_output.put_line('Updating PAYMENT table is not allowed');
END;

I know that LOCK TABLE statement with SHARE ROW EXCLUSIVE can be used, but is there a possibility that it will also block inserting data to a table?

Upvotes: 0

Views: 993

Answers (1)

h0merr
h0merr

Reputation: 212

Like the buddy who comment, you can REVOKE update privileges in your database, here is an example.

REVOKE UPDATE ON table to <username>

Information that might be useful:

GRANT creates a permission rule

REVOKE removes a permission rule

Upvotes: 5

Related Questions