0

我是 Oracle 可插拔数据库的新手(我们仍在使用 Oracle 11.2)。为了测试分区和子分区,我需要创建几十个表空间。我想,我会快速克隆我当前的数据库,进行测试,然后删除数据库。

我能够克隆数据库:

CREATE PLUGGABLE DATABASE ora193p2 FROM ora193p1
 FILE_NAME_CONVERT = (
   '/opt/oracle/oradata/ORA193C/ORA193P1/', 
   '/opt/oracle/oradata/ORA193C/ORA193P2/');

Pluggable database ORA193P2 created.

ORA-01109: database not open但在尝试连接时出错。

我试图打开它,但也收到一条错误消息(ora193c 是 cdb 的名称):

ALTER DATABASE ora193p2 OPEN;
ORA-01509: specified name 'ORA193P2' does not match actual 'ORA193C'

我使用了vagrant-boxes的数据库。

4

2 回答 2

2

对于可插拔数据库,您需要添加关键字可插拔数据库,后跟 pdb 名称

SQL> create pluggable database pdbclone from orclpdb;

Pluggable database created.


SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ORCLPDB                        READ WRITE NO
         4 PDBCLONE                       MOUNTED

SQL> alter pluggable database pdbclone open;

Pluggable database altered.


SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ORCLPDB                        READ WRITE NO
         4 PDBCLONE                       READ WRITE NO
SQL> alter pluggable database pdbclone save state;

Pluggable database altered.
于 2020-05-08T01:50:25.760 回答
1

此后,您可以通过CDB restart12.1.0.2保留 PDB 启动状态。引入的 12.1.0.2 补丁集和选项:SAVE STATEDISCARD STATE

ALTER PLUGGABLE DATABASE pdb_name OPEN;
ALTER PLUGGABLE DATABASE pdb_name SAVE STATE;

要丢弃保存的状态:

ALTER PLUGGABLE DATABASE pdb_name DISCARD STATE;

对于12.1.0.1和之前,您可以创建一个启动后触发器:

CREATE OR REPLACE TRIGGER open_pdbs 
  AFTER STARTUP ON DATABASE 
BEGIN 
   EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN'; 
END open_pdbs;
/

它在 CDB 中创建启动后系统级触发器。

请参阅Oracle 12c 安装后强制步骤

于 2020-05-08T08:15:10.917 回答