19c快速创建可拔插数据库 pluggable database pdb 租户

5770阅读 0评论2021-01-27 brjl
分类:Oracle

看当前的
SQL> show pdbs

    CON_ID CON_NAME           OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
SQL> !free -m
              total        used        free      shared  buff/cache   available
Mem:           4372         927         222        2649        3222         566
Swap:          6143         144        5999

SQL> create pluggable database PDBESB
  2  admin user adm identified by pwd
  3  file_name_convert=('pdbseed','pdbesb');

Pluggable database created.

SQL> show pdbs

    CON_ID CON_NAME          OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDBESB                         MOUNTED



从本地克隆
create pluggable database PDB2 from PDB1

file_name_convert=('pdb1','pdb2')

parallel 8;

创建完毕后新pdb是mount状态,需要open一下
alter pluggable database pdb2 open;

通过Database Link从远程克隆

create pluggable database PDB1 from PDB1@dblink_to_cdb1 file_name_convert=('CDB1','CDB2');


创建快照pdb
alter system set clonedb=true scope=spfile;
startup force
alter pluggable database pdb1 open read only;
create pluggable database pdbsnap1 from pdb1 snapshot copy file_name_convert('pdb1','pdbsnap');
alter pluggable database pdbsnap open;
--记得把pdb1设置为read write状态

删除旧的pdb
alter pluggable database pdb1 close;
drop pluggable database pdb1 including datafiles;

pdb改名
conn / as sysdba
sho pdbs
alter pluggable database &1 close immediate;
alter pluggable database &1 open restricted;
alter pluggable database &1 rename global_name to &2;
alter pluggable database &2 close immediate;
alter pluggable database &2 open;
sho pdbs
建议将上述脚本存为 renpdb.sql ,执行时:
SQL> @renpdb pdb1 pdbnew
上一篇:JDBC对照表
下一篇:expdp 分区表很慢