Oracle 12C CDB, PDB common management commands

Source: Internet
Author: User

--View PDB information (in CDB mode)

show pdbs   --查看所有pdbselect name,open_mode from v$pdbs;  --v$pdbs为PDB信息视图select con_id, dbid, guid, name , open_mode from v$pdbs;

--Switch container

alter session set container=orcl1   --切换到PDBorcl1容器alter session set container=CDB$ROOT    --切换到CDB容器

--See which container is currently belonging

select sys_context(‘USERENV‘,‘CON_NAME‘) from dual; --使用sys_context查看属于哪个容器show con_name   --用show查看当前属于哪个容器

--Start PDB

alter pluggable database orcl1 open;    --开启指定PDBalter pluggable database all open;  --开启所有PDBalter session set container=orcl1;  --切换到PDB进去开启数据库startup

--Close PDB

alter pluggable database orcl1 close;       --关闭指定的PDBalter pluggable database all close;     --关闭所有PDBalter session set container=orcl1;  --切换到PDB进去关闭数据库shutdown immediate

--Specify the location of the file map before creating or cloning (requires SYSDBA permissions in the CBD)

alter system set db_create_file_dest=‘/u01/app/oracle/oradata/orcl/orcl2‘;

--Create a new PDB: (Requires SYSDBA permissions under CBD)

create pluggable database test admin user admin identified by admin;    alter pluggable database test_pdb open;    --将test_pdb 打开

--Clone PDB (requires SYSDBA permissions under CBD)

create pluggable database orcl2 from orcl1;   --test_pdb必须是打开的,才可以被打开alter pluggable database orcl2 open;   --然后打开这个pdb

--Remove PDB (requires SYSDBA permissions under CBD)

alter pluggable database  orcl2 close;  --关闭之后才能删除drop pluggable database orcl2 including datafiles;  --删除PDB orcl2

--Set the CDB start PDB to start automatically (using a trigger here)

CREATE OR REPLACE TRIGGER open_pdbsAFTER STARTUP ON DATABASEBEGINEXECUTE IMMEDIATE ‘ALTER PLUGGABLE DATABASE ALL OPEN‘;END open_pdbs;/

Oracle 12C CDB, PDB common management commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.