詳談Oracle12c新特點容器資料庫&可插拔資料庫(CDB&PDB)
一般資訊
資料字典 |
|
|||||||||||||||||||||||||||||||||
角色 |
|
|||||||||||||||||||||||||||||||||
系統許可權 |
|
|||||||||||||||||||||||||||||||||
探究SEED PDB |
||||||||||||||||||||||||||||||||||
從PDB$SEED建立PDB |
語法: CREATE PLUGGABLE DATABASE ADMIN USER IDENTIFIED BY FILE_NAME_CONVERT = ('', '') ROLES = () DEFAULT TABLESPACE [DATAFILE ] EXTENT MANAGEMENT LOCAL <autoallocate |="" uniform="" size="" > STORAGE ];
例子: |
|||||||||||||||||||||||||||||||||
col con_name format a10 col restricted format a10 SELECT v.name, v.open_mode, v.restricted, d.status FROM v$pdbs v, dba_pdbs d WHERE v.guid = d.guid ORDER BY v.create_scn; NAME OPEN_MODE RESTRICTED STATUS ------------------------------ ---------- ---------- ------------- PDB$SEED READ ONLY NO NORMAL
ALTER PLUGGABLE DATABASE pdb1 OPEN; SELECT v.name, v.open_mode, v.restricted, d.status FROM v$pdbs v, dba_pdbs d WHERE v.guid = d.guid ORDER BY v.create_scn; NAME OPEN_MODE RESTRICTED STATUS ------------------------------ ---------- ---------- ------------- PDB$SEED READ ONLY NO NORMAL
SELECT * FROM dba_pdbs;
-- 12.1.0.1 version -- SELECT * FROM cdb$view(dba_pdbs); -- 12.1.0.2 versionSELECT * FROM containers(dba_pdbs); -- 12.1.0.1 version -- SELECT * FROM cdb$view(cdb_pdbs); -- 12.1.0.2 version SELECT * FROM containers(cdb_pdbs);
SELECT table_name, tablespace_name, con_id FROM containers(dba_tables) WHERE rownum < 6; |
||||||||||||||||||||||||||||||||||
|
CREATE PLUGGABLE DATABASE pdb1 ADMIN USER TEST IDENTIFIED BY TEST FILE_NAME_CONVERT = ('/pdbseed/', '/pdb1/');
SELECT v.name, v.open_mode, NVL(v.restricted, 'n/a') RESTRICTED, d.status FROM v$pdbs v, dba_pdbs d WHERE v.guid = d.guid ORDER BY v1; NAME OPEN_MODE RESTRICTED STATUS ------------------------------ ---------- ---------- ------------- PDB1 MOUNTED NO NORMAL PDB$SEED READ ONLY NO NORMAL
ALTER SESSION SET CONTAINER=pdb1;
sho con_name CON_NAME ------------------- PDB1
ALTER PLUGGABLE DATABASE pdb1 OPEN; SELECT COUNT(*)FROM dba_tables; |
|||||||||||||||||||||||||||||||||
探究資料檔案 |
desc dba_data_files desc cdb_data_files
SELECT file_name, tablespace_name, online_status FROM dba_data_files;
SELECT file_name, tablespace_name, online_status, con_id FROM cdb_data_files; |
|||||||||||||||||||||||||||||||||
探究使用者 |
desc dba_users desc cdb_users
SELECT username, account_status, lock_date, expiry_date FROM dba_users ORDER BY 1;
SELECT username, default_tablespace, temporary_tablespace FROM dba_users ORDER BY 1;
SELECT username, default_tablespace, temporary_tablespace, con_id FROM cdb_users ORDER BY 1;
SELECT username, default_tablespace, temporary_tablespace, con_id FROM cdb_users WHERE username like 'TE%' ORDER BY 1;
ALTER PLUGGABLE DATABASE pdb1 OPEN;
SELECT v.name, v.open_mode, NVL(v.restricted, 'n/a') "RESTRICTED", d.status FROM v$pdbs v, dba_pdbs d WHERE v.guid = d.guid ORDER BY v.create_scn;
NAME OPEN_MODE RESTRICTED STATUS ------------------------------ ---------- ---------- ------------- PDB$SEED READ ONLY NO NORMAL PDB1 READ WRITE NO NORMAL
SELECT username, default_tablespace, temporary_tablespace, con_id FROM cdb_users WHERE username like 'TE%' ORDER BY 1; |
|||||||||||||||||||||||||||||||||
連線建立PDB |
SQL> conn sys@pdb1 as sysdba Enter password: *********Connected.
SQL> GRANT create session TO TEST; Grant succeeded.
SQL> SELECT COUNT(*) FROM cdb_sys_privs; COUNT(*) 0
SQL> SELECT COUNT(*) FROM dba_sys_privs; COUNT(*) 987
SQL> SELECT privilege, admin_option, common FROM dba_sys_privs WHERE grantee = 'TEST';
PRIVILEGE ADM COM ---------------------------------------- --- --- CREATE SESSION NO NO
col grantee format a30 col granted_role format a30
SELECT * FROM dba_role_privs WHERE grantee = 'TEST'; GRANTEE GRANTED_ROLE ADM DEF COM ------------------------------ ------------------------------ --- --- --- TEST PDB_DBA YES YES NO |
|||||||||||||||||||||||||||||||||
克隆PDB |
||||||||||||||||||||||||||||||||||
從一個容器現有PDB克隆新的PDB |
語法: CREATE PLUGGABLE DATABASE FROM FILE_NAME_CONVERT=('', '<path'); </path');<>
例子: |
|||||||||||||||||||||||||||||||||
ALTER PLUGGABLE DATABASE pdb1 CLOSE; ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY;
CREATE OR REPLACE VIEW pdb_status AS SELECT v.name, v.open_mode, NVL(v.restricted, 'n/a') "RESTRICTED", d.status FROM v$pdbs v, dba_pdbs d WHERE v.guid = d.guid ORDER BY v.create_scn;
SELECT * FROM pdb_status; NAME OPEN_MODE RESTRICTED STATUS ------------------------------ ---------- ---------- ------------- PDB$SEED READ ONLY NO NORMAL PDB1 READ ONLY NO NORMAL
CREATE PLUGGABLE DATABASE pdb1_t FROM pdb1FILE_NAME_CONVERT = ('\uwpdb\', '\uwpdbd\'); SELECT * FROM pdb_status; NAME OPEN_MODE RESTRICTED STATUS ------------------------------ ---------- ---------- ------------- PDB$SEED READ ONLY NO NORMAL PDB1 READ ONLY NO NORMAL |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
建立時的UNPLUG/PLUGPDB |
||||||||||||||||||||||||||||||||||
Unplug 子句 |
||||||||||||||||||||||||||||||||||
Unplug 子句
從unplugged建立 |
語法: ALTER PLUGGABLE DATABASE UNPLUG INTO '';
例子: |
|||||||||||||||||||||||||||||||||
conn / as sysdba ALTER PLUGGABLE DATABASE pdb1 CLOSE; ALTER PLUGGABLE DATABASE pdb1 UNPLUG INTO 'pdb1.xml'; -- 將檔案ftp到新伺服器 -- the xml 檔案在 $ORACLE_HOME/database下
SQL> CREATE PLUGGABLE DATABASE pdb2 USING 'pdb1.xml' SOURCE_FILE_NAME_CONVERT = ('\pdb1\', '\pdb2\') NOCOPY STORAGE (MAXSIZE 1G MAX_SHARED_TEMP_SIZE 20M) TEMPFILE REUSE; |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
更改PDB |
||||||||||||||||||||||||||||||||||
設定子句 |
||||||||||||||||||||||||||||||||||
預設版本 |
語法: ALTER PLUGGABLE DATABASE
例子: |
|||||||||||||||||||||||||||||||||
conn / as sysdba ALTER SESSION SET CONTAINER = pdb1; CREATE EDITION test_ed; ALTER PLUGGABLE DATABASE pdb1 DEFAULT EDITION = test_ed; |
||||||||||||||||||||||||||||||||||
預設表空間 |
語法: ALTER PLUGGABLE DATABASE DEFAULT TABLESPACE ;
例子: |
|||||||||||||||||||||||||||||||||
conn / as sysdba
ALTER SESSION SET CONTAINER = pdb1; SELECT tablespace_nameFROM dba_tablespaces; ALTER PLUGGABLE DATABASE pdb1 DEFAULT TABLESPACE oradata; |
||||||||||||||||||||||||||||||||||
預設表空間型別 |
ALTER PLUGGABLE DATABASE SET DEFAULT TABLESPACE; |
|||||||||||||||||||||||||||||||||
conn / as sysdba ALTER SESSION SET CONTAINER = pdb1; ALTER PLUGGABLE DATABASE pdb1 SET DEFAULT BIGFILE TABLESPACE; |
||||||||||||||||||||||||||||||||||
預設臨時表空間 |
ALTER PLUGGABLE DATABASE DEFAULT TEMPORARY TABLESPACE ;; |
|||||||||||||||||||||||||||||||||
conn / as sysdba ALTER SESSION SET CONTAINER = pdb1; ALTER PLUGGABLE DATABASE pdb1 DEFAULT TEMPORARY TABLESPACEtemp_grp; |
||||||||||||||||||||||||||||||||||
重新命名 |
語法: ALTER PLUGGABLE DATABASE RENAME GLOBAL_NAME TO [.domain];
例子: |
|||||||||||||||||||||||||||||||||
conn / as sysdba ALTER SESSION SET CONTAINER = pdb1; SELECT *FROM global_name;
ALTER PLUGGABLE DATABASE pdb1 RENAME GLOBAL_NAME TO pdb$dev; |
||||||||||||||||||||||||||||||||||
PDB內設定時區 |
語法: ALTER PLUGGABLE DATABASE [] SET TIME_ZONE = ''; ALTER PLUGGABLE DATABASE SET TIME_ZONE = '< | -> HH:MI';
例子: |
|||||||||||||||||||||||||||||||||
conn sys@pdb1 as sysdba ALTER SESSION SET CONTAINER = pdb1; SELECT value$ FROM props$ WHERE name = 'DBTIMEZONE'; ALTER PLUGGABLE DATABASE pdb1 SET TIME_ZONE = 'Japan'; SELECT value$FROM props$WHERE name = 'DBTIMEZONE'; ALTER PLUGGABLE DATABASE pdb1 SET TIME_ZONE = '00:00'; SELECT value$FROM props$WHERE name = 'DBTIMEZONE'; |
||||||||||||||||||||||||||||||||||
資料檔案重新命名 |
語法: ALTER PLUGGABLE DATABASE RENAME FILE '' TO ''; |
|||||||||||||||||||||||||||||||||
例子: conn sys@pdb1 as sysdba
ALTER PLUGGABLE DATABASE CLOSE; RENAME FILE 'C:\APP\ORACLE\ORADATA\PDB1\PDB11.DBF' TO 'C:\APP\ORACLE\ORADATA\PDB1\PDB101.DBF'; --原資料檔案需手工去除 |
||||||||||||||||||||||||||||||||||
建立資料檔案 |
ALTER PLUGGABLE DATABASE CREATE DATAFILE <'' | filenumber> [AS | NEW] |
|||||||||||||||||||||||||||||||||
更改資料檔案 |
ALTER PLUGGABLE DATABASE DATAFILE <'' | filenumber> <online |="" offline="" [for="" drop]="" resize="" | | END BACKUP>; |
|||||||||||||||||||||||||||||||||
更改臨時檔案 |
ALTER PLUGGABLE DATABASE TEMPFILE <'' | filenumber> <resize |="" | DROP [INCLUDING DATAFILES] | ONLINE | OFFLINE>; |
|||||||||||||||||||||||||||||||||
移除資料檔案 |
ALTER PLUGGABLE DATABASE MOVE DATAFILE <'' | ASM_file_name | filenumber>TO '' [REUSE] [KEEP] |
|||||||||||||||||||||||||||||||||
補充日誌 |
語法: ALTER PLUGGABLE DATABASE SUPPLEMENTAL LOG <data |="" | > 例子: |
|||||||||||||||||||||||||||||||||
ALTER PLUGGABLE DATABASE pdb1 ADD SUPPLEMENTAL LOG DATA; |
||||||||||||||||||||||||||||||||||
儲存引數 |
語法: ALTER PLUGGABLE DATABASE STORAGE <unlimited |="" >; 例子: |
|||||||||||||||||||||||||||||||||
ALTER PLUGGABLE DATABASE pdb1 STORAGE UNLIMITED; |
||||||||||||||||||||||||||||||||||
例子: ALTER PLUGGABLE DATABASE STORAGE (MAX_SHARED_TEMP_SIZE <unlimited |="" ); 例子: |
||||||||||||||||||||||||||||||||||
ALTER PLUGGABLE DATABASE pdb1 STORAGE (MAX_SHARED_TEMP_SIZE UNLIMITED); |
||||||||||||||||||||||||||||||||||
Datafile子句 |
||||||||||||||||||||||||||||||||||
資料檔案聯機/離線 |
語法: ALTER PLUGGABLE DATABASE DATAFILE ALL ; |
|||||||||||||||||||||||||||||||||
例子: conn / as sysdba ALTER SESSION SET CONTAINER = pdb1; ALTER PLUGGABLE DATABASE pdb1 CLOSE; SELECT open_modeFROM v$pdbs; SELECT file#, status, enabledFROM v$datafile; ALTER PLUGGABLE DATABASE pdb1 DATAFILE ALL OFFLINE;
ALTER PLUGGABLE DATABASE pdb1 DATAFILE ALL ONLINE; SELECT file#, status, enabledFROM v$datafile;
ALTER PLUGGABLE DATABASE pdb1 OPEN; |
||||||||||||||||||||||||||||||||||
Recovery子句 |
||||||||||||||||||||||||||||||||||
備份和恢復PDB |
語法: ALTER PLUGGABLE DATABASE RECOVER [AUTOMATIC] [FROM '' DATABASE;例子: |
|||||||||||||||||||||||||||||||||
ALTER PLUGGABLE DATABASE pdb1 RECOVER AUTOMATIC DATABASE; |
||||||||||||||||||||||||||||||||||
語法: ALTER PLUGGABLE DATABASE BACKUP; 例子: |
||||||||||||||||||||||||||||||||||
conn / as sysdba SHUTDOWN IMMEDIATE; STARTUP MOUNT; ALTER DATABASE ARCHIVELOG; ALTER DATABASE OPEN; ALTER PLUGGABLE DATABASE pdb1 OPEN; ALTER SESSION SET CONTAINER = PDB1; ALTER PLUGGABLE DATABASE pdb1 BEGIN BACKUP; ALTER PLUGGABLE DATABASE pdb1 END BACKUP; |
||||||||||||||||||||||||||||||||||
Change 子句 |
||||||||||||||||||||||||||||||||||
讀寫模式開啟 |
語法: ALTER PLUGGABLE DATABASE OPEN READ [WRITE] [UPGRADE] [RESTRICTED] [FORCE][INSTANCES = <('' | <all [except="" (')] >); 例子: |
|||||||||||||||||||||||||||||||||
ALTER PLUGGABLE DATABASE pdb1 OPEN; |
||||||||||||||||||||||||||||||||||
只讀模式開啟 |
語法: ALTER PLUGGABLE DATABASE OPEN READ ONLY ; 例子: |
|||||||||||||||||||||||||||||||||
ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY; |
||||||||||||||||||||||||||||||||||
Resetlogs模式開啟 |
語法: ALTER PLUGGABLE DATABASE OPEN RESETLOGS ; 例子: |
|||||||||||||||||||||||||||||||||
ALTER PLUGGABLE DATABASE pdb1 OPEN RESETLOGS; |
||||||||||||||||||||||||||||||||||
開啟/關閉PDB |
語法: ALTER PLUGGABLE DATABASE CLOSE [IMMEDIATE]; |
|||||||||||||||||||||||||||||||||
例子: ALTER PLUGGABLE DATABASE pdb1 CLOSE; |
||||||||||||||||||||||||||||||||||
開啟/關閉所有PDB |
語法: ALTER PLUGGABLE DATABASE ALL CLOSE [IMMEDIATE]; |
|||||||||||||||||||||||||||||||||
例子: ALTER PLUGGABLE DATABASE ALL CLOSE; |
||||||||||||||||||||||||||||||||||
只讀模式開啟PDB |
語法: ALTER PLUGGABLE DATABASE READ ONLY; 例子: |
|||||||||||||||||||||||||||||||||
conn / as sysdba ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY; |
||||||||||||||||||||||||||||||||||
以READ ONLY RESTRICTED模式開啟PDB |
語法: ALTER PLUGGABLE DATABASE OPEN READ ONLY RESTRICTED; 例子: |
|||||||||||||||||||||||||||||||||
conn / as sysdbaALTER PLUGGABLE DATABASE pdb1 CLOSE;ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY RESTRICTED; |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
移除PDB |
||||||||||||||||||||||||||||||||||
從容器中刪除PDB |
語法: DROP PLUGGABLE DATABASE [INCLUDING DATAFILES]; 例子: |
|||||||||||||||||||||||||||||||||
ALTER PLUGGABLE DATABASE pdb1 CLOSE;DROP PLUGGABLE DATABASE pdb1 INCLUDING DATAFILES; |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8484829/viewspace-2132958/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- kettl連線oracle12c 可插拔資料庫pdbOracle資料庫
- 【kingsql分享】Oracle 18c可插拔資料庫艦隊新玩法SQLOracle資料庫
- 磁碟資料庫與記憶體資料庫的特點比較資料庫記憶體
- 淺析列式資料庫的特點NR資料庫
- 資料庫圈周盤點:資料庫執行管理員成新職業;資料庫公司Neon獲新融資資料庫
- 分散式資料庫的定義和特點分散式資料庫
- 崑崙分散式資料庫技術特點分散式資料庫
- 資料庫雜談(4)資料庫
- 資料庫雜談(2)資料庫
- 資料庫雜談(3)資料庫
- 淺談圖資料庫資料庫
- Oracle:容器資料庫簡介Oracle資料庫
- CentOS7 安裝Oracle12c資料庫CentOSOracle資料庫
- 資料庫圈周盤點:Serverless資料庫知多少資料庫Server
- 資料庫半月談(2022.12.25~2023.1.7)資料庫
- 淺談資料庫事務資料庫
- 關係型資料庫 RDBMS 的舊與新 — 談談 NewSQL資料庫SQL
- 【BUILD_ORACLE】在Oracle cloud資料庫“插拔”PDB的方法UIOracleCloud資料庫
- 什麼是mysql資料庫?MySQL的特點有哪些?MySql資料庫
- 資料庫趣談-五行資料庫
- 資料庫週刊18│4月資料庫排行;PG是最好的資料庫;TiDB 4.0新特性資料庫TiDB
- MySQL資料庫-鎖詳解MySql資料庫
- 談談中國資料治理的五大特點
- Django資料庫類庫MySQLdb使用詳解Django資料庫MySql
- Docker最全教程——資料庫容器化(十)Docker資料庫
- 詳解GuassDB資料庫許可權命令:GRANT和REVOKE資料庫
- 資料庫的許可權管理資料庫
- 資料庫PostrageSQL-管理資料庫資料庫SQL
- 今日談:BoltDB資料庫,一款純Go實現的KV資料庫資料庫Go
- 資料庫圈周盤點:資本正湧向分析型資料庫公司資料庫
- 【資料庫資料恢復】SAP資料庫資料恢復案例資料庫資料恢復
- 【資料庫資料恢復】MS SQL資料庫附加資料庫出錯怎麼恢復資料?資料庫資料恢復SQL
- [資料庫] 淺談mysql的serverId/serverUuid資料庫MySqlServerUI
- 資料湖 vs 倉庫 vs 資料庫資料庫
- 【Falsk 使用資料庫】---- 資料庫基本操作資料庫
- 資料庫概論 (一)資料庫概念資料庫
- 資料庫介紹--初識資料庫資料庫
- 資料庫 資料庫的完整性資料庫
- MySQL資料庫有哪些優勢特點?Linux學習有用嗎MySql資料庫Linux