您好,登錄后才能下訂單哦!
1、查看有多少pdb數據庫:
SQL> show pdbs;
2、切換到指定容器數據庫:
SQL> alter session set container=ORCLPDB;
3、啟動容器數據庫:
SQL> alter pluggable database ORCLPDB open;
4、關閉容器數據庫:
SQL> alter pluggable database ORCLPDB close immediate;
5、查看數據庫名字:
SQL> show con_name;
6、數據庫的創建及刪除:
--創建或克隆前要指定文件映射的位置(需要CBD下sysdba權限)
alter system set db_create_file_dest='/u01/app/oracle/oradata/orcl/orcl2';
--創建一個新的PDB:(需要CBD下sysdba權限)
create pluggable database test admin user admin identified by admin;
--不指定直接創建庫;
create pluggable database salespdb admin user admin identified by admin file_name_convert=('/u01/app/oracle/oradata/orcl12c/pdbseed/','/u01/app/oracle/oradata/orcl12c/salespdb/');
--克隆PDB(需要CBD下sysdba權限)
create pluggable database orcl2 from orcl1; --test_pdb必須是打開的,才可以被打開
--刪除PDB(需要CBD下sysdba權限)
alter pluggable database orcl2 close; --關閉之后才能刪除
drop pluggable database orcl2 including datafiles; --刪除PDB orcl2
--設置CDB啟動PDB自動啟動(在這里使用的是觸發器)
CREATE OR REPLACE TRIGGER open_pdbs
AFTER STARTUP ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN';
END open_pdbs;
7、PDB創建用戶(鏈接到pdb數據庫后創建用戶):
create user hanfuyou identified by hanfuyou default tablespace users temporary tablespace temp;
grant connect,resource,unlimited tablespace to hanfuyou;
拔插與刪除 PDB
1、拔出SALESPDB #必須連接到CDB$ROOT
#首先關閉SALESPDB
SQL> alter pluggable database SALESPDB close immediate;
SQL> alter pluggable database SALESPDB unplug into '/home/oracle/salespdb.xml';
#XML文件中包含了每個數據文件的位置,以及初始化參數等信息。
2、drop PDB
#關閉并且拔出PDB后才可以進行刪除,刪除時可以一起刪除數據文件:
#同樣需要連接到CDB$ROOT容器,執行下列語句:
SQL> drop pluggable database SALESPDB keep datafiles;
3、plug an unplugged PDB
#本機插入PDB
SQL> create pluggable database SALESPDB02 using '/home/oracle/salespdb.xml' nocopy tempfile reuse;
SQL> alter pluggable database SALESPDB02 open;
4、本機不同存放位置插入PDB
mkdir /u01/app/oracle/oradata/orcl12c/salespdb01/;
SQL> create pluggable database SALESPDB01 using '/home/oracle/salespdb.xml'
SOURCE_FILE_NAME_CONVERT=('/u01/app/oracle/oradata/orcl12c/salespdb/','/u01/app/salespdb/')
MOVE FILE_NAME_CONVERT=('/u01/app/salespdb/','/u01/app/oracle/oradata/orcl12c/salespdb01/')
PATH_PREFIX='/u01/app/oracle/oradata/orcl12c/salespdb01/' STORAGE (MAXSIZE 2G MAX_SHARED_TEMP_SIZE 100M);
這里xml文件中指示數據文件在/u01/app/oracle/oradata/orcl12c/salespdb/中,
而實際上數據文件在/u01/app/salespdb/中,
且最終我們要將數據文件放在/u01/app/oracle/oradata/orcl12c/salespdb01/中。
亂碼問題解決方法:
export NLS_LANG=american_america.AL32UTF8(把語句添加環境變量)
權限授權:
https://www.cnblogs.com/g253187360/p/8110442.html
https://www.cnblogs.com/SummerinShire/p/6539607.html
https://blog.csdn.net/Darker2016/article/details/84147293
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。