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))) |
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.