DEV Community

Vahid Yousefzadeh
Vahid Yousefzadeh

Posted on

Read-Only Session in Oracle 23ai

One of the new parameters introduced in Oracle 23ai is the read_only parameter:

SQL> show parameter READ_ONLY
NAME  TYPE        VALUE    
----- ----------- -------- 
read_only                            boolean     FALSE
Enter fullscreen mode Exit fullscreen mode

This parameter can only be configured at the session level. Setting this parameter to true disables the execution of DML and DDL statements within the session:

SQL> alter system set read_only=true scope=spfile;
ORA-32017: failure in updating SPFILE
ORA-02065: illegal option for ALTER SYSTEM
Enter fullscreen mode Exit fullscreen mode
 SQL> alter session set read_only=true;
Session altered.
SQL> delete tbl1;
ORA-28193: Can perform read operations only
SQL> drop table tbl1;
ORA-28193: Can perform read operations only
Enter fullscreen mode Exit fullscreen mode

If a transaction is active within the session, enabling this parameter is not allowed:

SQL> delete tbl1;
1 row deleted.

SQL> alter session set read_only=true;
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-65023: active transaction exists in container
Enter fullscreen mode Exit fullscreen mode

Top comments (0)