Chinaunix首页 | 论坛 | 博客
  • 博客访问: 773371
  • 博文数量: 185
  • 博客积分: 7434
  • 博客等级: 少将
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-29 14:01
文章分类

全部博文(185)

文章存档

2013年(1)

2012年(2)

2011年(17)

2010年(25)

2009年(36)

2008年(104)

分类: Oracle

2008-09-16 15:48:49

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.
 
阅读(1051) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~