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

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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值