Saturday, April 6, 2013

Alter table read only in Oracle 11g

Alter table read only in Oracle 11g...

Administrator can restrict DML operations on a table

                    1.Using Alter table command(oracle 11g)

                     2.Using Triggers.

How to make a table as read only in oracle database(11g)


//11g feature.
Syntax:
Alter table <tablename> read only;  



for ex:   

Alter table emp read only;



How to make Read only table to  read write/allow DML operations.



Alter table emp read write;



How to make table as Read only using Triggers.

create or replace trigger custReadonly
before insert or delete or update on customer
begin
if( inserting or deleting or updating) then

 raise_application_error(-20300,'Customer table does not allow DML operations');
end if;
end;

Enable or Disable  Trigger(Allow DML operations).



Alter trigger  custReadonly   disable.

Enable trigger


Alter trigger  custReadonly   enable.

Tags: Read only tables in oracle 11g, Readonly tables, Alter table readonly, alter table read write, Oracle Read only tables, restrict DML operations on oracle table, How to make table as read only in oracle,how to make readonly table as read write in oracle database.

No comments:

Post a Comment