Oracle 多租户CDB/PDB操作汇总

来源:互联网 发布:云脉文档识别 mac 编辑:程序博客网 时间:2024/05/16 18:42
--查看当前数据库是否为CDB
SELECT NAME, CDB, CON_ID FROM V$DATABASE;


--查看CDB中可用的service:


col name format a20
col pdb format a20
set linesize 200
select name,pdb from v$services;


--切换会话到pdb


alter session set container=tstpdb1;
alter session set container=CDB$ROOT;


show con_name;




--关闭和开启pdb


alter pluggable database tstpdb1 close;
alter pluggable database tstpdb1 open;




col guid format a40
col name format a20
col open_mode format a20
set linesize 200
select con_id, dbid, guid, name , open_mode from v$pdbs;




--创建pdb 必须是sysdba
CREATE PLUGGABLE DATABASE tstpdb4 FROM tstpdb3;
drop pluggable database tstpdb4 keep datafiles/including datafiles; 




--插拔pdb数据库
alter pluggable database tstpdb2 close;


alter pluggable database tstpdb2 unplug into '/home/oracle/unplugged_pdbs/tstpdb2.xml';


drop pluggable database tstpdb2 keep datafiles;


col guid format a40
col name format a20
col open_mode format a20
set linesize 200
select con_id, dbid, guid, name , open_mode from v$pdbs;


create pluggable database tstpdb3 using '/home/oracle/unplugged_pdbs/tstpdb2.xml' nocopy tempfile reuse;


create pluggable database tstpdb2
using '/home/oracle/unplugged_pdbs/tstpdb3.xml' 
source_file_name_convert=('/dbfile/oradata/TST105/5C6C107CD9651BA1E05369283CA8C983/datafile/','/dbfile/oradata/TST105/tstpdb2/datafile/');




create pluggable database tstpdb2
using '/home/oracle/unplugged_pdbs/tstpdb3.xml' 
source_file_name_convert=('/dbfile/oradata/TST105/5C6C107CD9651BA1E05369283CA8C983/datafile/','/dbfile/oradata/TST105/tstpdb2/datafile/')
move 
file_name_convert=('/location2/','/location3/')
path_prefix='/location3/'
storage (maxsize 2g max_shared_temp_size 100m);
原创粉丝点击