I am offered (by some framework) to run commands in sqlplus, but am not launching it myself. I'd like to know the version of that sqlplus running.
4 Answers
Within SQL*Plus, there are some preDEFINEd substitution variable:
SQL> define
DEFINE _DATE = "23-NOV-13" (CHAR)
DEFINE _CONNECT_IDENTIFIER = "" (CHAR)
DEFINE _USER = "" (CHAR)
DEFINE _PRIVILEGE = "" (CHAR)
DEFINE _SQLPLUS_RELEASE = "1102000100" (CHAR)
DEFINE _EDITOR = "Notepad" (CHAR)
Notice the _SQLPLUS_RELEASE. You reference this in SQLPLUS.
For example, you can do something like:
sqlplus -S /nolog<<EOF
prompt &_SQLPLUS_RELEASE
quit
EOF
I don't think you can with an actual query. You may be able to get it with this:
SELECT
PROGRAM, MODULE
from v$session s
order by s.sid;
The Module column may contain the version number, it might not. It depends on the program. If memory serves correctly, sqlplus does not give this. For example, TOAD gives "TOAD Freeware 11.0.0.116"
You can also just connect to sqlplus through commande line. In LINUX you can do the following:
[orafresh@ljsrv1123 ~]$ sqlplus / as sysdba
Which will return:
SQL*Plus: Release 11.1.0.7.0 - Production on Fri Jul 14 12:47:36 2017
Copyright (c) 1982, 2008, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options