Read-Only Tables in Oracle Database 11g
来源:互联网 发布:人体工学椅 知乎 编辑:程序博客网 时间:2024/06/14 03:26
In previous Oracle releases, tables could be made to appear read-only to other users by only granting theSELECT
object privilege to them, but the tables remained read-write for the owner. Oracle 11g allows tables to be marked as read-only using theALTER TABLE
command.
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 UPDATE
queries 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_ONLY
column of the[DBA|ALL|USER]_TABLES
views.
- Read-Only Tables in Oracle Database 11g
- Exploring Oracle 11g Database nternals with x$ Tables
- 只读表(Read-only)--Oracle 11g 新特性
- Virtual Columns in Oracle Database 11g
- using audit in oracle database 11g
- Oracle Database 11G Services in Windows
- Virtual Columns in Oracle Database 11g
- Dropping and creating tables in read only tablespaces?!
- Using Transparent Database Encryption in Oracle Database 11g
- tables in database
- Table Compression Enhancements in Oracle Database 11g Release 1
- Adaptive Cursor Sharing in Oracle Database 11g Release 1
- Adaptive Cursor Sharing in Oracle Database 11g
- All about rowid in Oracle Database 11g
- Temporary Tablespace Enhancements in Oracle Database 11g
- About Password Expiration in Oracle Database 11g
- Oracle 11g 新特性 -- 只读表(read-only table)说明
- Oracle 11g 新特性 -- 只读表(read-only table)
- uva - 10098 - Generating Fast
- Jenkins安装及制作快捷启动脚本相关
- 实现文件的上传
- TCP建链为何一定要三次握手?
- Note for Sybase
- Read-Only Tables in Oracle Database 11g
- sql server 存储过程和触发器
- 深入理解JVM内幕:从基本结构到Java 7新特性
- 【live555】OutPacketBuffer粗浅分析
- Oracle查询表空间使用大小,使用率,剩余大小,百分比
- 判断输入是否为日期类型
- 2014DNS事件始末
- Codeforces Round #225 (Div. 1) B. Volcanoes
- MD5加密字符串处理