3.通过现有的PDB创建一个新的PDB
Session altered.
SQL> conn dsg/dsg@emp
Connected.
SQL> create table test (id number(8));
Table created.
SQL> begin
2 for i in 1..100 loop
3 insert into test values(i);
4 end loop;
5 commit;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> select count(*) from test;
COUNT(*)
----------
100
Connected.
SQL> create pluggable database emptest from emp;
create pluggable database emptest from emp
*
ERROR at line 1:
ORA-65081: database or pluggable database is not open in read only mode
----源数据库必须在read only状态
SQL> alter pluggable database emp close;
Pluggable database altered.
SQL> alter pluggable database emp open read only;
Pluggable database altered.
SQL> create pluggable database emptest from emp;
Pluggable database created.
EMPTEST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = EMPTEST) ) ) |
create pluggable database emptest from emp Sun Jan 19 22:26:48 2014 **************************************************************** Pluggable Database EMPTEST with pdb id - 4 is created as UNUSABLE. If any errors are encountered before the pdb is marked as NEW, then the pdb must be dropped **************************************************************** Deleting old file#7 from file$ Deleting old file#8 from file$ Deleting old file#9 from file$ Adding new file#12 to file$(old file#7) Adding new file#13 to file$(old file#8) Adding new file#14 to file$(old file#9) Successfully created internal service emptest at open ALTER SYSTEM: Flushing buffer cache inst=0 container=4 local **************************************************************** Post plug operations are now complete. Pluggable database EMPTEST with pdb id - 4 is now marked as NEW. **************************************************************** Completed: create pluggable database emptest from emp |
[oracle@localhost datafile]$ lsnrctl status LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 19-JAN-2014 22:31:31 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.1.0.1.0 - Production Start Date 14-JAN-2014 10:29:20 Uptime 5 days 12 hr. 2 min. 11 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost.localdomain)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/ora12c/xdb_wallet))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "emp" has 1 instance(s). Instance "ora12c", status READY, has 1 handler(s) for this service... Service "emptest" has 1 instance(s). Instance "ora12c", status READY, has 1 handler(s) for this service... Service "ora12c" has 1 instance(s). Instance "ora12c", status READY, has 1 handler(s) for this service... Service "ora12cXDB" has 1 instance(s). Instance "ora12c", status READY, has 1 handler(s) for this service... The command completed successfully |
alter pluggable database emptest rename global_name to emp_test
*
ERROR at line 1:
ORA-65046: operation not allowed from outside a pluggable database
SQL> alter pluggable database emptest close;
alter pluggable database emptest close
*
ERROR at line 1:
ORA-65020: pluggable database EMPTEST already closed
下面以RESTRICTED 模式打开数据库
SQL> alter pluggable database emptest open restricted;
Pluggable database altered.
SQL> conn sys/oracle@emptest as sysdba
Connected.
SQL> alter pluggable database emptest rename global_name to emp_test;
Pluggable database altered.
SQL> select service_id,name,pdb from v$services;
SERVICE_ID NAME PDB
---------- ---------------------------------------------------------------- ------------------------------
1 emp_test EMP_TEST
SQL> conn / as sysdba
Connected.
SQL> select service_id,name,pdb from v$services;
SERVICE_ID NAME PDB
---------- ---------------------------------------------------------------- ------------------------------
1 emp_test EMP_TEST
6 emp EMP
3 ora12cXDB CDB$ROOT
4 ora12c CDB$ROOT
1 SYS$BACKGROUND CDB$ROOT
2 SYS$USERS CDB$ROOT
6 rows selected.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。