Read-Only Tables in Oracle Database 11g
2014-01-23 14:47
453 查看
In previous Oracle releases, tables could be made to appear read-only to other users by only granting the
The following script creates a table, inserts a row, then sets the table to read-only.
Any DML statements that affect the table data and
DDL statements that affect the table data are also restricted,但是只读模式的表可以用drop命令删除。
Operations on indexes associated with the table are unaffected by the read-only state. DML and DDL operations return to normal once the table is switched back to read-write mode.
The read-only status of tables is displayed in the
SELECTobject privilege to them, but the tables remained read-write for the owner. Oracle 11g allows tables to be marked as read-only using the
ALTER TABLEcommand.
ALTER TABLE table_name READ ONLY; ALTER TABLE table_name READ WRITE;
The following script creates a table, inserts a row, then sets the table to read-only.
CREATE TABLE ro_tab ( id NUMBER ); INSERT INTO ro_tab VALUES (1); ALTER TABLE ro_tab READ ONLY;
Any DML statements that affect the table data and
SELECT ... FOR UPDATEqueries result in an ORA-12081 error message.
SQL> INSERT INTO ro_tab VALUES (2); INSERT INTO ro_tab VALUES (2) * ERROR at line 1: ORA-12081: update operation not allowed on table "TEST"."RO_TAB" SQL> UPDATE ro_tab SET id = 2; UPDATE ro_tab SET id = 2 * ERROR at line 1: ORA-12081: update operation not allowed on table "TEST"."RO_TAB" SQL> DELETE FROM ro_tab; DELETE FROM ro_tab * ERROR at line 1: ORA-12081: update operation not allowed on table "TEST"."RO_TAB"
DDL statements that affect the table data are also restricted,但是只读模式的表可以用drop命令删除。
SQL> TRUNCATE TABLE ro_tab; TRUNCATE TABLE ro_tab * ERROR at line 1: ORA-12081: update operation not allowed on table "TEST"."RO_TAB" SQL> ALTER TABLE ro_tab ADD (description VARCHAR2(50)); ALTER TABLE ro_tab ADD (description VARCHAR2(50)) * ERROR at line 1: ORA-12081: update operation not allowed on table "TEST"."RO_TAB"
Operations on indexes associated with the table are unaffected by the read-only state. DML and DDL operations return to normal once the table is switched back to read-write mode.
SQL> ALTER TABLE ro_tab READ WRITE; Table altered. SQL> DELETE FROM ro_tab; 1 row deleted. SQL>
The read-only status of tables is displayed in the
READ_ONLYcolumn of the
[DBA|ALL|USER]_TABLESviews.
相关文章推荐
- Adaptive Cursor Sharing in Oracle Database 11g Release 1
- Data Guard Physical Standby Setup in Oracle Database 11g Release 2
- Virtual Columns in Oracle Database 11g
- 107.Note the following points describing various utilities in Oracle Database 11g:
- 只读表(Read-only)--Oracle 11g 新特性
- Database '' is in warm standby. A warm-standby database is read-only.
- 用户、补丁-Create Oracle ASM Cluster File Systems (ACFS) in Oracle Database 11g Release 2-by小雨
- 转载:Data Guard Physical Standby Setup in Oracle Database 11g Release 2
- Oracle 11g新特性之--只读表(read only table)
- 184 You are in the process of creating a Virtual Private Catalog (VPC) in your Oracle Database 11g d
- Using Transparent Database Encryption in Oracle Database 11g
- HIVE A read-only user or a user in a read-only database is not permitted to disable read-only mode
- Online Table Redefinition Enhancements in Oracle Database 11g Release 1
- Partitioning Enhancements in Oracle Database 11g Release 1
- Oracle:PIVOT and UNPIVOT Operators in Oracle Database 11g Release 1
- Data Guard Physical Standby Setup in Oracle Database 11g Release 2
- oracle 11g rac启动报错ORA-01102: cannot mount database in EXCLUSIVE mode
- How to switch to another database in oracle 11g(如何在oracle中从一个数据库切换到另一个数据库)
- DDL With the WAIT Option (DDL_LOCK_TIMEOUT) in Oracle Database 11g Release 1
- Oracle:Virtual Columns in Oracle Database 11g Release 1