加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle设置表空间/单个表的只读属性

发布时间:2020-12-12 14:04:34 所属栏目:百科 来源:网络整理
导读:Oracle可以使用alter tablespace/table xxx read only设置表空间/单个表的只读属性,并使用alter tablespace/table xxx read write解除只读属性。 环境 :Oracle 12c 测试过程 : 1. 设置表空间的只读属性 SQL create table t1(id int) tablespace tbs1; Tab
Oracle可以使用alter tablespace/table xxx read only设置表空间/单个表的只读属性,并使用alter tablespace/table xxx read write解除只读属性。

环境:Oracle 12c

测试过程

1. 设置表空间的只读属性
SQL> create table t1(id int) tablespace tbs1;

Table created.

SQL> insert into t1 values(111);

1 row created.

SQL> alter tablespace tbs1 read only;

Tablespace altered.

SQL> select * from t1;

ID
----------
111

SQL> insert into t1 values(111);
insert into t1 values(111)
*
ERROR at line 1:
ORA-00372: file 13 cannot be modified at this time
ORA-01110: data file 13: '/home/oracle/app/oracle/oradata/orcl/tbs01.dbf'

2. 解除表空间只读属性
SQL> alter tablespace tbs1 read write;

Tablespace altered.

SQL> insert into t1 values(112);

1 row created.

3. 设置单个表的只读属性

SQL> alter table t1 read only;

Table altered.

SQL> insert into t1 values(113);
insert into t1 values(113)
*
ERROR at line 1:
ORA-12081: update operation not allowed on table "SYS"."T1"

4. 解除单个表的只读属性
SQL> alter table t1 read write;

Table altered.

SQL> insert into t1 values(114); 1 row created.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读