2.oracle 12c 建立-訪問-關閉-刪除PDB

來源:互聯網
上載者:User

標籤: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中查看:
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.