Read-Only Tables Oracle Database 11g introduces new ALTER TABLE syntax. For example: ALTER TABLE READ ONLY and ALTER TABLE READ WRITE
The operating system sets the precedent to make a file read-only even for its owner. Earlier, a table could be made read-only (by granting only SELECT on it) to users other than the owner of the table. With this feature, the owner too can be prevented from doing unintended DML to a table.
可以用alter table
read only命令,把某张表改为只读,从而阻止在此表上进行DML操作.
例:
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production PL/SQL Release 11.1.0.6.0 - Production CORE 11.1.0.6.0 Production TNS for Linux: Version 11.1.0.6.0 - Production NLSRTL Version 11.1.0.6.0 - Production
SQL> create table t as select * from dba_users; Table created.
SQL> select count(*) from t; COUNT(*) ---------- 31
SQL> insert into t select * from t; 31 rows created.
SQL> select count(*) from t; COUNT(*) ---------- 62
SQL> alter table t read only; --置为只读 Table altered.
SQL> select count(*) from t;
COUNT(*) ---------- 62
SQL> insert into t select * from t; --DML失败 insert into t select * from t * ERROR at line 1: ORA-12081: update operation not allowed on table "SYS"."T"
SQL> alter table t read write; --置为可读可写 Table altered.
SQL> insert into t select * from t; --DML成功 62 rows created.