In Oracle 11g, we can change the table to READ ONLY mode which doesn't allow any DML over it.
Below is a tested scenario.
SQL> alter table scott.emp read only;
Table altered.
SQL> select
owner,
table_name,
read_only from dba_tables
where owner='SCOTT'
and table_name='OBJECTS';
OWNER TABLE_NAME READ_ONLY
---------- --------------- ---------------
SCOTT EMP YES
SQL> update scott.emp
set owner='SCOTT';
update objects
*
ERROR at line 1:
ORA-12081: update operation not allowed on table "EMP"."SCOTT"
SQL> delete from scott.emp where empno = 7369;
ERROR at line 1:
ORA-12081: update operation not allowed on table "SCOTT"."EMP"
Now change the mode of table to read write again.
SQL> alter table scott.emp read write;
Table altered.
SQL> select owner,table_name,read_only from dba_tables where owner='SCOTT'
2 and table_name='EMP';
OWNER TABLE_NAME READ_ONLY
---------- --------------- ---------------
SCOTT EMP NO
SQL> truncate table SCOTT.EMP;
Table truncated.
No comments:
Post a Comment