首先是修改glogin.sql文件
[oracle@home01 admin]$ vi glogin.sql
Define _editor = 'vi'
set time on
set termout off
column propmt_c new_value propmt_c
SELECT SYS_CONTEXT ('USERENV', 'CON_NAME') as propmt_c FROM DUAL;
set sqlprompt "_user'@'_connect_identifier(&propmt_c)> "
然后登入sqlplus测试
[oracle@home01 admin]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Sun Oct 15 15:34:40 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options
15:34:40 SYS@PRODCDB(CDB$ROOT)> alter session set container=pdb1;
实验总结:可以看出来这个sqlprompt,只在刚进sqlplus的时候作校验,之后不会再发生变动,如果使用alter session set container的方式来修改当前容器的话,结果就是sqlprompt不会跟着意识到容器的变化,而是维持刚登入时获得的con_name,但是如果用conn sys/oracle@pdbprod1 as sysdba的方式重新登入,sqlprompt就会发生改变