CDB、PDB相关管理命令
在Oracle数据库中,CDB(Container Database)和PDB(Pluggable Database)是多租户体系结构的核心组件。以下是一些常见的CDB和PDB管理命令:
- 创建PDB:
CREATE PLUGGABLE DATABASE pdb1 ADMIN USER pdb_admin IDENTIFIED BY password
FILE_NAME_CONVERT = ('pdbseed', 'pdb1') PATH_PREFIX = '/u01/app/oracle/oradata/cdb1/pdb1/';
- 打开PDB:
ALTER PLUGGABLE DATABASE pdb1 OPEN;
- 关闭PDB:
ALTER PLUGGABLE DATABASE pdb1 CLOSE IMMEDIATE;
- 删除PDB:
DROP PLUGGABLE DATABASE pdb1 INCLUDING DATAFILES;
- 列出所有PDB:
SELECT pdb_id, con_id, dbid, guid, name, open_mode FROM cdb_pdbs;
- 切换当前容器到指定的PDB:
ALTER SESSION SET CONTAINER=pdb1;
- 在CDB中创建新的PDB模板:
CREATE PLUGGABLE DATABASE pdb_template ADMIN USER pdb_admin IDENTIFIED BY password
PATH '/u01/app/oracle/oradata/cdb1/pdb_template/'
FILE_NAME_CONVERT = ('pdbseed', 'pdb_template');
- 使PDB保持打开状态:
ALTER PLUGGABLE DATABASE pdb1 SAVE STATE;
- 使PDB恢复到关闭状态:
ALTER PLUGGABLE DATABASE pdb1 SUSPEND;
- 重命名PDB:
ALTER PLUGGABLE DATABASE pdb1 RENAME TO pdb2;
注意:以上命令可能需要在特定的上下文中执行,例如在SQL*Plus或SQLcl中,并且可能需要相应的权限。在执行这些操作之前,请确保您有适当的权限和数据库的备份。
评论已关闭