標籤:des style blog http color 使用 os io
1.建立PDBSQL> select name from v$datafile; NAME--------------------------------------------------------------------------------/u01/app/oracle/oradata/ora12c/system01.dbf/u01/app/oracle/oradata/ora12c/pdbseed/system01.dbf/u01/app/oracle/oradata/ora12c/sysaux01.dbf/u01/app/oracle/oradata/ora12c/pdbseed/sysaux01.dbf/u01/app/oracle/oradata/ora12c/undotbs01.dbf/u01/app/oracle/oradata/ora12c/users01.dbf/u01/app/oracle/oradata/ora12c/EMP/system01.dbf/u01/app/oracle/oradata/ora12c/EMP/sysaux01.dbf/u01/app/oracle/oradata/ora12c/EMP/EMP_users01.dbf 9 rows selected.SQL> alter system set db_create_file_dest=‘/u01/app/oracle/oradata/ora12c/dsg‘; System altered. SQL> create pluggable database dsg admin user hxy identified by hxy roles=(connect); Pluggable database created.要先設定db_create_file_dest,否則建立PDB的時候報下面的錯誤:SQL> create pluggable database dsg admin user hxy identified by hxy roles=(connect);create pluggable database dsg admin user hxy identified by hxy roles=(connect) *ERROR at line 1:ORA-65016: FILE_NAME_CONVERT must be specified查看SQL> select con_id,name,open_mode from v$pdbs; CON_ID NAME OPEN_MODE---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 EMP READ WRITE 4 DSG MOUNTED啟動DSGSQL> alter pluggable database dsg open;Pluggable database altered. SQL> select con_id,name,open_mode from v$pdbs; CON_ID NAME OPEN_MODE---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 EMP READ WRITE 4 DSG READ WRITE 2.
(1)通過tnsname訪問PDB資料庫例如:查看當前資料庫的PDBSQL> select con_id,name,open_mode from v$pdbs; CON_ID NAME OPEN_MODE---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 EMP READ WRITE查看tnsnames.oraEMP = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = EMP) ) ) 訪問:[[email protected] ~]$ sqlplus sys/[email protected] as sysdbaSQL*Plus: Release 12.1.0.1.0 Production on Sat Jan 18 14:26:04 2014Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> show con_name con_idCON_NAME------------------------------EMP CON_ID------------------------------3
(2)使用EZCONNECT方式串連到資料庫SQL> conn sys/[email protected]//localhost/dsg as sysdbaConnected. SQL> show con_name con_id CON_NAME------------------------------DSG CON_ID------------------------------
4 查看SQL> select name from v$datafile; NAME------------------------------------------------------------------------------------------------------------------------/u01/app/oracle/oradata/ora12c/undotbs01.dbf/u01/app/oracle/oradata/ora12c/dsg/ORA12C/F039E431F9CE7170E0430100007F6A0D/datafile/o1_mf_system_9fn895qv_.dbf/u01/app/oracle/oradata/ora12c/dsg/ORA12C/F039E431F9CE7170E0430100007F6A0D/datafile/o1_mf_sysaux_9fn89mpk_.dbf有兩個單獨的資料檔案system、sysaux和共用的undo資料表空間共用的全域資料檔案SQL> select name from v$tempfile; NAME------------------------------------------------------------------------------------------------------------------------/u01/app/oracle/oradata/ora12c/dsg/ORA12C/F039E431F9CE7170E0430100007F6A0D/datafile/o1_mf_temp_9fn8bxy4_.dbf有獨立的臨時檔案 SQL> select name from v$controlfile; NAME------------------------------------------------------------------------------------------------------------------------/u01/app/oracle/oradata/ora12c/control01.ctl/u01/app/oracle/fast_recovery_area/ora12c/control02.ctl控制檔案是共用的
(3)在DBA等進階許可權的使用者下,通過alter命令進行會話層級的容器切換,訪問不同容器下的對象SQL> conn / as sysdbaConnected.SQL> alter session set container=dsg;Session altered. SQL> show con_id con_nameCON_ID------------------------------4CON_NAME------------------------------DSG SQL> alter session set container=emp;Session altered. SQL> show con_id con_nameCON_ID------------------------------3CON_NAME------------------------------EMP
五,關閉PDB
(1)切換到PDBSQL> alter session set container=dsg;Session altered. SQL> show con_id con_nameCON_ID------------------------------4CON_NAME------------------------------DSG SQL> shutdown immediatePluggable Database closed.
(2)在具有sys許可權的使用者執行SQL> alter pluggable database emp close;Pluggable database altered. 六,刪除PDBSQL> select con_id,name,open_mode from v$pdbs; CON_ID NAME OPEN_MODE---------- ------------------------------ ---------- 2 PDB$SEED READ ONLY 3 EMP MOUNTED 4 DSG READ WRITE SQL> drop pluggable database dsg including datafiles;drop pluggable database dsg including datafiles*ERROR at line 1:ORA-65025: Pluggable database DSG is not closed on all instances.
必須讓PDB處於關閉狀態才能刪除PDB SQL> alter pluggable database dsg close;Pluggable database altered. SQL> drop pluggable database dsg including datafiles;Pluggable database dropped. 查看產生的alert日誌:把相應的資料檔案全部刪除在OS中查看: