[20240912]21c设置会话参数read-only.txt

来源:这里教程网 时间:2026-03-03 20:36:45 作者:

[20240912]21c设置会话参数read-only.txt --//21c支持设置会话参数read-only,简单测试如下: 1.环境: SCOTT@book01p> @ver2 ============================== PORT_STRING                   : x86_64/Linux 2.4.xx VERSION                       : 21.0.0.0.0 BANNER                        : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production BANNER_FULL                   : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production Version 21.3.0.0.0 BANNER_LEGACY                 : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production CON_ID                        : 0 PL/SQL procedure successfully completed. 2.测试: SCOTT@book01p> create table deptx as select * from dept; Table created. SCOTT@book01p> create sequence seq1 cache 5; Sequence created. SCOTT@book01p> show parameter read_only PARAMETER_NAME         TYPE     VALUE ---------------------- -------- ------- hybrid_read_only       boolean  FALSE read_only              boolean  FALSE read_only_open_delayed boolean  FALSE SCOTT@book01p> alter session set read_only=true; Session altered. SCOTT@book01p> create index  pk_deptx on deptx(deptno); create index  pk_deptx on deptx(deptno) * ERROR at line 1: ORA-16000: database or pluggable database open for read-only access SCOTT@book01p> create sequence seq2; create sequence seq2 * ERROR at line 1: ORA-16000: database or pluggable database open for read-only access SCOTT@book01p> delete from deptx; delete from deptx             * ERROR at line 1: ORA-16000: database or pluggable database open for read-only access SCOTT@book01p> truncate table deptx; truncate table deptx * ERROR at line 1: ORA-16000: database or pluggable database open for read-only access SCOTT@book01p> select seq1.nextval,dept.* from dept;    NEXTVAL     DEPTNO DNAME                          LOC ---------- ---------- ------------------------------ -------------          2         10 ACCOUNTING                     NEW YORK          3         20 RESEARCH                       DALLAS          4         30 SALES                          CHICAGO          5         40 OPERATIONS                     BOSTON SCOTT@book01p> select seq1.nextval,dept.* from dept;    NEXTVAL     DEPTNO DNAME                          LOC ---------- ---------- ------------------------------ -------------          6         10 ACCOUNTING                     NEW YORK          7         20 RESEARCH                       DALLAS          8         30 SALES                          CHICAGO          9         40 OPERATIONS                     BOSTON --//使用中涉及到的sequence没有问题. SCOTT@book01p> select * from dept for update; select * from dept for update               * ERROR at line 1: ORA-16000: database or pluggable database open for read-only access --//可以设置登录触发器,设置一些用户只读查询: create or replace trigger logon_trg after logon on scott.schema declare begin   execute immediate 'alter session set read_only=true'; end; /

相关推荐