脚本
代码语言:javascript复制-- 步骤1、启动pdb到受限模式(在pdb里边操作)
alter session set container=pdblhr3;
alter pluggable database pdblhr3 close immediate;
alter pluggable database pdblhr3 open restricted;
-- 或:
shutdown immediate
startup open restrict
-- 步骤2、进入pdb里边对pdb进行重命名
alter session set container=pdblhr3;
select * from global_name;
alter pluggable database pdblhr3 rename global_name to pdbprod3;
-- 步骤3、正常关闭和启动pdb
alter pluggable database close immediate;
alter pluggable database open;
-- 或
shutdown immediate
startup
例如:将JDE重命名为JDEPROD
代码语言:javascript复制alter pluggable database JDE close immediate;
alter pluggable database JDE open restricted;
alter session set container=JDE;
alter pluggable database rename global_name to JDEPROD;
alter pluggable database close immediate;
alter pluggable database open;
注意事项
1、必须进入目标PDB中才可以对其进行重命名,否则报错“ORA-65046: operation not allowed from outside a pluggable database”。
2、在修改完成后,监听里的service_name已经自动被修改了。所以,如果配置了相关的tnsnames.ora文件,那么就需要同时手工去修改该文件。