O Oracle Multitenant já está presente em nossas vidas há algum tempo, esta arquitetura nos ajuda a consolidar vários bancos de dados como PDBs em um CDB container.
Arquitetura Multitenant:
Informações do servidor:
[root@srv03 ~]# cat /etc/*-release | grep PRETTY
PRETTY_NAME="Oracle Linux Server 7.9"
[oracle@srv03 ~]$ uname -a
Linux srv03 5.4.17-2136.315.5.el7uek.x86_64 #2 SMP Wed Dec 21 19:57:57 PST 2022 x86_64 x86_64 x86_64 GNU/Linux
Informações do Database:
set lines 200
col DATABASE_HOST for a25;
col DB_UNIQUE_NAME for a25
col HOST_NAME for a15;
col DATABASE_ROLE for a10
col OPEN_MODE for a10
col STARTUP_TIME for a20
alter session set nls_date_format = 'DD/MM/YYYY HH24:MI:SS';
SELECT i.HOST_NAME "DATABASE_HOST" ,
i.INSTANCE_NAME "DB_NAME",
d.db_unique_name "DB_UNIQUE_NAME" ,
d.DATABASE_ROLE " DATABASE_ROLE",
i.VERSION,
d.OPEN_MODE " OPEN_MODE ",
d.LOG_MODE
,STARTUP_TIME
from GV$DATABASE d, gv$instance i
where i.INST_ID=d.INST_ID;
DATABASE_HOST DB_NAME DB_UNIQUE_NAME DATABASE_ROLE VERSION OPEN_MODE LOG_MODE STARTUP_TIME
------------------------- ---------------- ------------------------- ---------------- ----------------- -------------------- ------------ --------------------
srv03 prd19 prd19 PRIMARY 19.0.0.0.0 READ WRITE ARCHIVELOG 24/02/2023 22:09:16
Edição do database:
set lines 200
select BANNER_LEGACY from gv$version;
BANNER_LEGACY
--------------------------------------------------------------------------------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
PDB existentes no servidor:
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
4 HML READ WRITE NO
Fechando e iniciando o PDB HML como restricted:
SQL> alter pluggable database HML close immediate;
Pluggable database altered.
SQL> alter pluggable database HML open restricted;
Pluggable database altered.
Confirmando o status de restricted do PDB HML:
SQL> show PDBS;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
4 HML READ WRITE YES <================
Conectando no PDB para realizar o rename de HML para DEV:
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> alter session set container=HML;
Session altered.
SQL> show con_name
CON_NAME
------------------------------
HML
SQL> alter pluggable database rename global_name to DEV;
Pluggable database altered.
Fechando o PDB e iniciando ja com o nome DEV:
SQL> alter session set container=CDB$ROOT;
Session altered.
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> alter pluggable database DEV close immediate;
Pluggable database altered.
SQL> alter pluggable database DEV open;
Pluggable database altered.
Listando todos os PDBs:
SQL> show PDBS;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
4 DEV READ WRITE NO <=================
SQL>
Ao utilizar o database com Multitenant, encontramos diversas facilidades, uma delas é poder renomear um PDB de forma simples.