2. Với CDB 12c/18c/19c/21c :
Oracle Database 12c/18c/19c/21c tạo thêm các PDB1, PDB2,... (tên PDB có thể là sale, marketing, customer,...)
2.1. Các câu lệnh với CDB
- Kiểm tra xem Database của mình có là CDB hay không.
$ sqlplus / as sysdba
SQL>
SELECT
CDB
FROM
V$
DATABASE
;
- Thông tin CDB:
SQL> SHOW CON_NAME
SQL> select INSTANCE_NUMBER, INSTANCE_NAME, status from gv$instance;
INSTANCE_NUMBER INSTANCE_NAME STATUS
--------------- ---------------- ------------
1 orcl OPEN
SQL> select inst_id,name, open_mode from gv$database;
INST_ID NAME OPEN_MODE
---------- --------- --------------------
1 ORCL READ WRITE
- Chuyển sang CDB:
SHOW CON_NAME
ALTER SESSION SET container = cdb$root;
2.2. Các câu lệnh với PDB
SHOW pdbs;
SELECT name, open_mode FROM v$pdbs;
- Chuyển sang PDB1:
SHOW CON_NAME
ALTER SESSION SET container = pdb1;
- Bật/tắt PDB: SQL> ALTER PLUGGABLE DATABASE pdb1 OPEN;
- Có thể bật tắt như sau:
+ Bật:
- Truy vấn thông tin các PDB:
SELECT name, open_mode FROM v$pdbs; -- Khuyến cáo sử dụng
COLUMN PDB_NAME FORMAT A15
SELECT PDB_ID, PDB_NAME, STATUS FROM DBA_PDBS ORDER BY PDB_ID;SELECT PDB_ID, PDB_NAME, STATUS FROM CDB_PDBS ORDER BY PDB_ID;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
- Các câu lệnh khác chuyển qua lại giữa pdb1 và cdb$root:
SHOW CON_NAME
ALTER SESSION SET container = pdb1;
ALTER SESSION SET container = cdb$root;
3. Bật Oracle Enterprise Manager Express
SELECT DBMS_XDB_CONFIG.gethttpport FROM dual;
SELECT DBMS_XDB_CONFIG.gethttpsport FROM dual;
EXEC DBMS_XDB_CONFIG.sethttpsport(5500);
https://192.168.182.128:5500/em/
- Chuyển sang PDB1:
SHOW CON_NAME
ALTER SESSION SET container = pdb1;
SQL> ALTER PLUGGABLE DATABASE pdb1, pdb2 OPEN READ ONLY FORCE;
SQL> ALTER PLUGGABLE DATABASE pdb1 CLOSE IMMEDIATE;
SQL> ALTER PLUGGABLE DATABASE pdb1, pdb2 CLOSE IMMEDIATE;
SQL> ALTER PLUGGABLE DATABASE ALL OPEN;
SQL> ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE;
SQL> ALTER PLUGGABLE DATABASE ALL EXCEPT pdb1 OPEN;
SQL> ALTER PLUGGABLE DATABASE ALL EXCEPT pdb1 CLOSE IMMEDIATE;
- Có thể bật tắt như sau:
SQL> SHOW CON_NAME
SQL> ALTER SESSION SET container = pdb1;
+ Bật:
SQL> startup
+ Tắt:
SQL> shutdown immediate;
+ Tắt:
SQL> shutdown immediate;
SQL> SHOW CON_NAME
SQL> ALTER SESSION SET container = pdb2;
+ Bật:
SQL> startup
+ Tắt:
SQL> shutdown immediate;
+ Tắt:
SQL> shutdown immediate;
SELECT name, open_mode FROM v$pdbs; -- Khuyến cáo sử dụng
COLUMN PDB_NAME FORMAT A15
SELECT PDB_ID, PDB_NAME, STATUS FROM DBA_PDBS ORDER BY PDB_ID;
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
- Các câu lệnh khác chuyển qua lại giữa pdb1 và cdb$root:
SHOW CON_NAME
ALTER SESSION SET container = pdb1;
ALTER SESSION SET container = cdb$root;
3. Bật Oracle Enterprise Manager Express
SELECT DBMS_XDB_CONFIG.gethttpport FROM dual;
SELECT DBMS_XDB_CONFIG.gethttpsport FROM dual;
EXEC DBMS_XDB_CONFIG.sethttpsport(5500);
https://192.168.182.128:5500/em/