[26ai] Hybrid Read-Only Mode PDB
![[26ai] Hybrid Read-Only Mode PDB](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F23e8f92e-f89b-4746-930e-98156e3a1ec4.png&w=3840&q=75)
If you prefer to read in Spanish Spanish version.
Today, let's talk about a new Hybrid Read-Only open-mode in 26ai.
When we set up this mode, our PDB is read-only mode for local users and read-write for common users.
So, let's get down to business!
First of all, let's create a new PDB:
SQL> CREATE PLUGGABLE DATABASE PDB_HYBRID ADMIN USER admin IDENTIFIED BY admin keystore identified by external store;
Pluggable database created.
SQL> ALTER PLUGGABLE DATABASE PDB_HYBRID OPEN;
Pluggable database altered.
SQL> ALTER PLUGGABLE DATABASE PDB_HYBRID SAVE STATE;
Pluggable database altered.
Let's create both users:
SQL> CREATE USER c##hybrid IDENTIFIED BY "XXXXXXX";
User created.
SQL> GRANT DBA TO c##hybrid CONTAINER=ALL;
Grant succeeded.
SQL> alter session set container=pdb_hybrid;
SQL> create smallfile tablespace tb1
datafile size 1m autoextend on maxsize 10m;
Tablespace created.
SQL> CREATE USER hybrid IDENTIFIED BY "XXXXXXX"
DEFAULT TABLESPACE tb1
TEMPORARY TABLESPACE temp
QUOTA UNLIMITED ON tb1;
User created.
SQL> GRANT DBA TO hybrid;
Grant succeeded.
All right, we have just created both users, on one hand, the common user is c##hybrid. On the other hand, the local user is hybrid .
Before opening it with the new state, let's connect as local user in order to create a table with some information:
SQL> conn hybrid/"XXXXX"@X.X.X.X:1521/pdb_hybrid.XXXX.XXXX.XXXX.com
Connected.
SQL>
SQL>
Create table T_TEST AS
SELECT OBJECT_NAME FROM ALL_OBJECTS;
Table created.
Let's connect to CDB$Root in order to open the PDB in hybrid read-only mode.
SQL> alter pluggable database PDB_HYBRID close;
Pluggable database altered.
SQL> alter pluggable database PDB_HYBRID open hybrid read only;
Pluggable database altered.
SQL> r
select con_name,
open_mode,
is_hybrid_read_only
from v$container_topology
CON_NAME OPEN_MODE IS_HYBRID_READ_ONLY
-------------------- ---------- --------------------
CDB$ROOT READ WRITE NO
PDB$SEED READ ONLY NO
PDB_HYBRID READ WRITE YES
Let's connect as local user in order to execute DML (delete) and DDL (truncate).
SQL> conn hybrid/"XXXXX"@X.X.X.X:1521/pdb_hybrid.XXXX.XXXX.XXXX.com
Connected.
SQL> set linesize 1000
SQL> col name format a20
SQL> select name, open_mode from v$pdbs;
NAME OPEN_MODE
-------------------- ----------
PDB_HYBRID READ ONLY
SQL> delete T_TEST;
delete T_TEST
*
ERROR at line 1:
ORA-16000: Attempting to modify database or pluggable database that is open for read-only access.
Help: https://docs.oracle.com/error-help/db/ora-16000/
SQL> truncate table T_TEST;
truncate table T_TEST
*
ERROR at line 1:
ORA-16000: Attempting to modify database or pluggable database that is open for read-only access.
Help: https://docs.oracle.com/error-help/db/ora-16000/
Both operations failed with the following message "ORA-16000: Attempting to modify database or pluggable database that is open for read-only access"
Let's connect as the common user in order to performn the same operations.
SQL> conn c##hybrid/"FJA_2026_Oracle19c"
Connected.
SQL> alter session set container=PDB_HYBRID;
Session altered.
SQL> select name, open_mode from v$pdbs;
NAME OPEN_MODE
-------------------- ----------
PDB_HYBRID READ WRITE
SQL> delete hybrid.T_TEST;
52165 rows deleted.
SQL> truncate table hybrid.T_TEST;
Table truncated.
Both operations completed sucessfully.
Before calling it a day, when we check v$pdbs as local user, the value in OPEN_MODE is READ ONLY, whereas, the value for common user is READ WRITE.
Looking forward to seeing you in the next article :)
![[26ai] ALERT_LOG_MAX_SIZE](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2Fdad5c53e-425c-4e82-9bbb-e0ccec6e9a4e.jpg&w=3840&q=75)
![[26ai] ConnStr Tool](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F8316641c-ac22-45c3-a59d-4a8a7dfd9de5.png&w=3840&q=75)
![[26ai] Install Oracle AI Database 26ai on Linux 9](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F243000b4-ccef-4cab-97db-f9b47328159f.png&w=3840&q=75)
![[OCI] Mount a Bucket as a FS](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F4dc1fa32-8048-442d-a214-b279e7730939.png&w=3840&q=75)