龙空技术网

"sqlplus / as sysdba" 能直接连接到PDB吗?

人类机器人 58

前言:

眼前我们对“sqlplus用户连接oracle”大体比较注重,各位老铁们都想要了解一些“sqlplus用户连接oracle”的相关知识。那么小编在网摘上网罗了一些有关“sqlplus用户连接oracle””的相关资讯,希望朋友们能喜欢,我们快快来学习一下吧!

答案是:

YES:19c ( or 18.8)以后

NO:12.1,12.2

==TEST==

正常连接到CDB.

$ export | grep SIDdeclare -x ORACLE_SID="CDB193"$ sqlplus / as sysdbaSQL*Plus: Release 19.0.0.0.0 - Production on Sun May 10 04:19:38 2020Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle.  All rights reserved.Connected to:Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.3.0.0.0SQL> show pdbs    CON_ID CON_NAME			  OPEN MODE  RESTRICTED---------- ------------------------------ ---------- ----------	 2 PDB$SEED			  READ ONLY  NO	 3 PDB				  READ WRITE NOSQL> show con_nameCON_NAME------------------------------CDB$ROOTSQL> 
连接到PDB
$ export ORACLE_PDB_SID=PDB$ export |grep SIDdeclare -x ORACLE_PDB_SID="PDB"declare -x ORACLE_SID="CDB193"$ $ sqlplus / as sysdbaSQL*Plus: Release 19.0.0.0.0 - Production on Sun May 10 04:20:40 2020Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle.  All rights reserved.Connected to:Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.3.0.0.0SQL> show pdbs    CON_ID CON_NAME			  OPEN MODE  RESTRICTED---------- ------------------------------ ---------- ----------	 3 PDB				  READ WRITE NOSQL> show con_nameCON_NAME------------------------------PDB
记得去掉刚才的设置,否则直接连接到PDB。
=== unset===$ unset ORACLE_PDB_SID$ export | grep SIDdeclare -x ORACLE_SID="CDB193"$

Q: 这有什么用啊?

A:可以帮助写自动化脚本的DBA。

20c和18.8也是可以的

Refer:

Can you connect as SYSDBA without password into a PDB directly?Can you?

Our answer always was: No. You can’t. There is no bequeath connection available.

....

标签: #sqlplus用户连接oracle