Difference between revisions of "Read only Table"

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search
(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 ...")
 
Line 30: Line 30:
 
   
 
   
 
Table altered
 
Table altered
</pre>
+
 
SQL> select table_name, read_only from user_tables where table_name='EMP';
 
SQL> select table_name, read_only from user_tables where table_name='EMP';
 
   
 
   
Line 36: Line 36:
 
------------------------------ ---------
 
------------------------------ ---------
 
EMP                            NO
 
EMP                            NO
 
+
</pre>
 
[[Category:Database_Features]]
 
[[Category:Database_Features]]

Revision as of 19:10, 14 March 2011

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