Difference between revisions of "Read only Table"
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 ...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 22: | Line 22: | ||
update EMP set SAL=2000 where ENAME='SMITH' | update EMP set SAL=2000 where ENAME='SMITH' | ||
− | ORA-12081: update operation not allowed on table " | + | ORA-12081: update operation not allowed on table "USER1"."EMP" |
</pre> | </pre> | ||
Line 30: | Line 30: | ||
Table altered | Table altered | ||
− | + | ||
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]] |
Latest 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 "USER1"."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