linux12c建非cdb数据库,Oracle 12C 将Non-PDB插入到CDB中

进入到非CDB数据库中

查看数据文件的位置

[Oracle@shuang ~]$ sqlplus  / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Wed Feb 26 13:17:45 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area 1060585472 bytes

Fixed Size    2296472 bytes

Variable Size  704644456 bytes

Database Buffers  348127232 bytes

Redo Buffers    5517312 bytes

SQL> select name from v$datafile;

NAME

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/SHUANG/datafile/o1_mf_system_9jckkfwg_.dbf

/u01/app/oracle/oradata/SHUANG/datafile/o1_mf_sysaux_9jckdvs6_.dbf

/u01/app/oracle/oradata/SHUANG/datafile/o1_mf_undotbs1_9jckpbno_.dbf

/u01/app/oracle/oradata/SHUANG/datafile/o1_mf_users_9jckp97s_.dbf

查看数据库为Non-CDB数据库

SQL> select name ,cdb from v$database;

NAME          CDB

---------            ---

SHUANG  NO

建立测试用户以及表

SQL> conn a/a

Connected.

SQL> select count(*) from a;

COUNT(*)

----------

1024

使用dbms_pdb包进行迁移,dbms_pdb是12c新增加的,为了方便迁移用的。可以用desc dbms_pdb查看下具体参数。

将Non-CDB数据库迁移到CDB数据库,得先将Non-CDB数据库设置为只读数据库,再进行进一步操作。

SQL> shut immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

[oracle@shuang ~]$ sqlplus  / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Wed Feb 26 13:17:45 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount

ORACLE instance started.

Total System Global Area 1060585472 bytes

Fixed Size      2296472 bytes

Variable Size    704644456 bytes

Database Buffers    348127232 bytes

Redo Buffers      5517312 bytes

Database mounted

SQL>alter database open read only;

Database altered.

SQL> exec dbms_pdb.describe(PDB_DESCR_FILE=>'/u01/app/oracle/oradata/SHUANG/datafile/shuang12c.xml');

PL/SQL procedure successfully completed.

SQL> host ls -l /u01/app/oracle/oradata/SHUANG/datafile/shuang12c.xml

-rw-r--r-- 1 oracle oinstall 4123  2月 26 12:50 /u01/app/oracle/oradata/SHUANG/datafile/shuang12c.xml

SQL> shut immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

在CDB中执行PLUG,就可以将这个Non-CDB插入CDB中,指定COPY参数,将文件复制到CDB的相应目录下,如果已经复制到特定目录,则可以指定NOCOPY选项,就无需再复制一遍。

进入到CDB数据库中。

SQL>create pluggable database shuang using '/u01/app/oracle/oradata/SHUANG/datafile/shuang12c.xml' copy ;

PL/SQL procedure successfully completed.

SQL> select name,open_mode from v$pdbs;

NAME        OPEN_MODE

------------------------------ ----------

PDB$SEED        READ ONLY

PDBORCL      MOUNTED

SHUANG        READ WRITE

SQL> alter session set container=shuang;

Session altered.

SQL> select count(*) from a.a;

COUNT(*)

----------

1024

0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值