您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“Oracle 12c如何創(chuàng)建和刪除PDB”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“Oracle 12c如何創(chuàng)建和刪除PDB”這篇文章吧。
1. 手工創(chuàng)建PDB
從SEED database 創(chuàng)建PDB的時(shí)候,可以指定文件存放的位置。 有兩種方法可以指定文件的位置。
第一種是在CREATE PLUGGABLE DATABASE 語法中添加FILE_NAME_CONVERT選項(xiàng)。
http://www.cndba.cn/dave/article/221
http://www.cndba.cn/dave/article/221
SQL> set lin 120 SQL> col name for a60 SQL> select * from v$dbfile; 13 /u01/app/oracle/oradata/dave/pdb1/ado2.dbf 3 14 /u01/app/oracle/oradata/dave/pdb1/cndba01.dbf 3 22 /u01/app/oracle/oradata/dave/cndba/system.dbf 4 23 /u01/app/oracle/oradata/dave/cndba/sysaux.dbf 4 24 /u01/app/oracle/oradata/dave/cndba/users.dbf 4 25 /u01/app/oracle/oradata/dave/cndba/ado1.dbf 4 26 /u01/app/oracle/oradata/dave/cndba/ado2.dbf 4 18 rows selected.
查看PDB的位置,創(chuàng)建新目錄:
[oracle@Ora12c ~]$ mkdir /u01/app/oracle/oradata/dave/huaining SQL> create pluggable database huaining admin user cndba identified by cndba file_name_convert=('/u01/app/oracle/oradata/dave/pdbseed/','/u01/app/oracle/oradata/dave/huaining/'); Pluggable database created.
也可以簡寫:http://www.cndba.cn/dave/article/221
create pluggable database huaining admin user cndba identified by cndba file_name_convert=('pdbseed','huaining'); SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO 4 CNDBA READ WRITE NO 5 HUAINING MOUNTED
--查看PDB的狀態(tài):是NEW,測試是不可用的。
http://www.cndba.cn/dave/article/221
SQL> set lin 120 SQL> col pdb_name for a15 SQL> select pdb_name,status from dba_pdbs; PDB_NAME STATUS --------------- --------- PDB1 NORMAL PDB$SEED NORMAL CNDBA NORMAL HUAINING NEW
必須顯示的打開數(shù)據(jù)庫:http://www.cndba.cn/dave/article/221
SQL> alter pluggable database huaining open; Pluggable database altered. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO 4 CNDBA READ WRITE NO 5 HUAINING READ WRITE NO SQL> select pdb_name,status from dba_pdbs; PDB_NAME STATUS --------------- --------- PDB1 NORMAL PDB$SEED NORMAL CNDBA NORMAL HUAINING NORMAL
第二種方法,就是先指定PDB_FILE_NAME_CONVERT 參數(shù)的值,然后執(zhí)行創(chuàng)建命令,此時(shí)就不需要指定FILE_NAME_CONVERT選項(xiàng)。
http://www.cndba.cn/dave/article/221
[oracle@Ora12c pdbseed]$ mkdir /u01/app/oracle/oradata/dave/ahdba SQL> show parameter pdb_ NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ pdb_file_name_convert string pdb_lockdown string pdb_os_credential string SQL> alter session set pdb_file_name_convert='/u01/app/oracle/oradata/dave/pdbseed/','/u01/app/oracle/oradata/dave/ahdba/'; Session altered. SQL> show parameter pdb_ NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ pdb_file_name_convert string /u01/app/oracle/oradata/dave/p dbseed/, /u01/app/oracle/orada ta/dave/ahdba/ pdb_lockdown string pdb_os_credential string SQL> SQL> create pluggable database ahdba admin user cndba identified by cndba; Pluggable database created. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO 4 CNDBA READ WRITE NO 5 HUAINING READ WRITE NO 6 AHDBA MOUNTED SQL> alter pluggable database ahdba open; Pluggable database altered. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO 4 CNDBA READ WRITE NO 5 HUAINING READ WRITE NO 6 AHDBA READ WRITE NO SQL>
2. 手工刪除PDB
在刪除PDB的時(shí)候,有2個(gè)選項(xiàng) KEEP DATAFILES 和 including DATAFILES,默認(rèn)是KEEP.
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO 4 CNDBA READ WRITE NO 5 HUAINING READ WRITE NO 6 AHDBA READ WRITE NO SQL> drop pluggable database huaining; drop pluggable database huaining * ERROR at line 1: ORA-65179: cannot keep datafiles for a pluggable database that is not unplugged SQL> !oerr ora 65179 65179, 00000, "cannot keep datafiles for a pluggable database that is not unplugged" // *Cause: An attempt was made to drop a pluggable database without // specifying the INCLUDING DATAFILES clause, and the pluggable // database has not been unplugged. // *Action: Unplug the pluggable database before dropping the pluggable // database or use the INCLUDING DATAFILES clause in the // DROP PLUGGABLE DATABASE statement. // SQL> drop pluggable database huaining including datafiles; Pluggable database dropped. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO 4 CNDBA READ WRITE NO 6 AHDBA READ WRITE NO SQL> 操作系統(tǒng)層面看,對(duì)應(yīng)的文件,也一起刪除了:[oracle@Ora12c huaining]$ pwd /u01/app/oracle/oradata/dave/huaining[oracle@Ora12c huaining]$ ls[oracle@Ora12c huaining]$
如果是使用KEEP datafiles,那么在執(zhí)行drop 之前,必須先執(zhí)行unplug的操作。
SQL> drop pluggable database ahdba keep datafiles; drop pluggable database ahdba keep datafiles * ERROR at line 1: ORA-65179: cannot keep datafiles for a pluggable database that is not unplugged SQL> alter pluggable database ahdba unplug into '/tmp/ahdba.xml'; Pluggable database altered. SQL> drop pluggable database ahdba keep datafiles; Pluggable database dropped.
刪除成功。
以上是“Oracle 12c如何創(chuàng)建和刪除PDB”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。