Read only Table

From Ittichai Chammavanijakul's Wiki
Revision as of 19:09, 14 March 2011 by Ittichai (talk | contribs) (Created page with "A table can be set READ ONLY mode to restrict write operations. * Enable table for READ-ONLY <pre> SQL> alter table EMP read only; Table altered </pre> * The READ_ONLY column ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A table can be set READ ONLY mode to restrict write operations.

  • Enable table for READ-ONLY
SQL> alter table EMP read only; 
Table altered
  • The READ_ONLY column of the user_tables confirms the change.
SQL> select table_name, read_only from user_tables where table_name='EMP';
 
TABLE_NAME                     READ_ONLY
------------------------------ ---------
EMP                            YES
  • Making an attempt to do DML will fail.
SQL> update EMP set SAL=2000 where ENAME='SMITH';
 
update EMP set SAL=2000 where ENAME='SMITH'
 
ORA-12081: update operation not allowed on table "AUDIT_USER"."EMP"
  • Enable table for READ-WRITE
SQL> alter table EMP read write;
 
Table altered

SQL> select table_name, read_only from user_tables where table_name='EMP';

TABLE_NAME READ_ONLY


---------

EMP NO