Oracle 12c 常用操作命令
1多实例切换
export ORACLE_SID=实例名
例如:
2登陆数据库
sqlplus / as sysdba
注意:
CDB与PDB之前的切换可参考上篇文章
3查看当前实例或者说当前容器
select name from v$database;
或者
show con_name
例如:
- SQL> select name from v$database;
- NAME
- ---------
- PROONE
4查看当前容器的pdb
show con_name;
例子:
- SQL> alter session set container=PROONEPDB01;
- Session altered.
- SQL> show con_name;
- CON_NAME
------------------------------
PROONEPDB01
5查看pdb 状态
select con_id,guid,dbid,name,open_mode from v$pdbs;
例子:
- SQL> select con_id,guid,dbid,name,open_mode from v$pdbs;
- CON_ID GUID DBID
- ---------- -------------------------------- ----------
- NAME
- --------------------------------------------------------------------------------
- OPEN_MODE
- ----------
- 3 8D5445F2984AB2A3E0559D634B6F5BE0 4177436042
- PROONEPDB01
- MOUNTED
现在的状态只是mounted 只是被挂载,并没有打开
6修改pdb 状态
打开pdb:
alter pluggable database PROONEPDB01 open;
例子:
- SQL> alter pluggable database PROONEPDB01 open;
- Pluggable database altered.
- SQL> select name,open_mode from v$pdbs;
- NAME
- --------------------------------------------------------------------------------
- OPEN_MODE
- ----------
- PROONEPDB01
- READ WRITE
关闭pdb:
alter pluggable database PROONEPDB01 close;
例子:
- SQL> alter pluggable database PROONEPDB01 close;
- Pluggable database altered.
- SQL> select name,open_mode from v$pdbs;
- NAME
- --------------------------------------------------------------------------------
- OPEN_MODE
- ----------
- PROONEPDB01
- MOUNTED