Get the Oracle Version using CMD - oracle

Is there is any command to find my installed oracle version from windows command prompt. (just like java -version..)

You need to locate ORACLE_HOME directory, to set it as environment variable and then to run opatch:
set ORACLE_HOME=...
"ORACLE_HOME"\OPatch\opatch lspatches
This command lists the installed patches with the Oracle major version.

You can use the below to get the database version by navigating to the ORACLE_HOME directory
$ORACLE_HOME\OPatch\opatch lsinventory | find "Oracle Database"

Well, that depends on what you really have.
If you have installed Oracle onto your PC (such as my 11gXE), then you could try sqlplus -v:
c:\Temp>sqlplus -v
SQL*Plus: Release 11.2.0.2.0 Production
11.2.0.2.0; is that really so?
c:\Temp>sqlplus scott/tiger
SQL*Plus: Release 11.2.0.2.0 Production on Sri Svi 6 07:40:29 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>
Yes, it is. I use SQL*Plus 11.2.0.2.0 which connects me to 11.2.0.2.0 database.
However, if I don't have Oracle installed on my PC but it is somewhere on database server and I access it via network, then it won't work because it'll display SQL*Plus (i.e. client installed on my PC), not database version. Besides, I can have several clients installed, so it depends on which sqlplus executable I ran.
Database version - in such a case - can't be retrieved from operating system command prompt only (at least, I don't know how to do it). You can obtain it by connecting to the database itself, e.g.
Client version:
M:\>sqlplus -v
SQL*Plus: Release 11.2.0.1.0 Production
ORCL database version is 11.2.0.4.0
M:\>sqlplus scott/tiger#orcl
SQL*Plus: Release 11.2.0.1.0 Production on Sri Svi 6 08:12:27 2020
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
ORCL2 database version is 10.2.0.5.0:
M:\>sqlplus scott/tiger#orcl2
SQL*Plus: Release 11.2.0.1.0 Production on Sri Svi 6 08:13:42 2020
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, Data Mining and Real Application Testing options
SQL>
When you're in SQL*Plus, query v$version, e.g.
SQL> select * From v$version where rownum = 1;
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
SQL>
which shows that I'm currently connected to 12.2.0.1.0.

This code allows you to display only the version of the database.
#echo off
set user_name=scott
set password=tiger
set net_service_name=edcu
set sql=select version from PRODUCT_COMPONENT_VERSION where rownum=1;
(echo conn %user_name%/%password%#%net_service_name%
echo set heading off
echo %sql%
echo exit) |sqlplus -s /nolog
For example output
D:\upwork\stackoverflow\get_version_oracle>get_oracle_version.bat
11.2.0.3.0

Related

Oracle DB - Connecting 11gR2 DB from 19c Client - ORA-12650 : No Common Encryption or data integrity algorithm

We have Oracle 19c Client installed in our application Unix server.
When we connect to a 19c Database server from our application Unix server, it is working as expected.
But when we try Connecting 11gR2 Database schema using sqlplus from our application server, getting the error ORA-12650 : No Common Encryption or data integrity algorithm
From our application Unix server, we did a tnsping with the connect descriptor we had used. TNSPING is working fine from our application server.
etladm#myappserver992[DEV][admin] $ tnsping MYOLD_DB_DEV
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 15-MAR-2021 01:36:00
Copyright (c) 1997, 2019, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/client/19c/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =my11gr2dbserverdaas)(PORT = 1622))) (CONNECT_DATA = (SERVICE_NAME = DEV.hk.myorg.com)))
OK (450 msec)
etladm#myappserver992[DEV][admin] $
Note:
In our application server we have both Oracle 11gR2 Oracle client as well as 19c Oracle client are installed due to other module's dependencies. But Unix PATH variable is set to point Oracle 19c Oracle home path
etladm#myappserver992[DEV][~] $ echo $ORACLE_HOME
/u01/app/oracle/product/client/19c
etladm#myappserver992[DEV][~] $
sqlnet.ora found in our 19c Client admin directory:
# Forces Network Data Encryption during Transit
NAMES.DIRECTORY_PATH=(EZCONNECT,TNSNAMES)
SQLNET.ENCRYPTION_CLIENT = REQUIRED
SQLNET.ENCRYPTION_TYPES_CLIENT = AES256
SQLNET.CRYPTO_CHECKSUM_CLIENT = REQUIRED
SQLNET.CRYPTO_CHECKSUM_TYPES_CLIENT = SHA256
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
# SQLNET.ALLOWED_LOGON_VERSION_CLIENT=12
We are unable to upgrade our 11gR2 DB currently. So looking for any settings at sqlnet.ora or somewhere.
Edit #1: We are able to connect to 12c Oracle DB server from our application server using 19c sqlplus.
etladm#myappserver992[DEV][admin] $ sqlplus username/password#my12cdbserversilos:1624/DEV.uk.myorg.com
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Mar 15 01:48:17 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Mon Mar 15 2021 01:46:36 +08:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> select * from v$version;
BANNER CON_ID
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
PL/SQL Release 12.2.0.1.0 - Production 0
CORE 12.2.0.1.0 Production 0
TNS for Linux: Version 12.2.0.1.0 - Production 0
NLSRTL Version 12.2.0.1.0 - Production 0
SQL>
Edit #2:
11g Server Version:
select * from v$version;
BANNER
----------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
"CORE 11.2.0.4.0 Production"
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
SQLNET.ORA in 11g Server:
NAMES.DIRECTORY_PATH= (TNSNAMES, LDAP, EZCONNECT)
SQLNET.ENCRYPTION_SERVER=REQUESTED
SEC_USER_AUDIT_ACTION_BANNER=/u01/app/oracle/global/scripts/BANNER/dbbanner.txt
Your 19c client sqlnet.ora requires a SHA256 checksum:
SQLNET.ENCRYPTION_CLIENT = REQUIRED
SQLNET.ENCRYPTION_TYPES_CLIENT = AES256
SQLNET.CRYPTO_CHECKSUM_CLIENT = REQUIRED
SQLNET.CRYPTO_CHECKSUM_TYPES_CLIENT = SHA256
Oracle 11gR2 only supports the SQLNET.CRYPTO_CHECKSUM_TYPES_SERVER value SHA1. See documentation here: https://docs.oracle.com/cd/E11882_01/network.112/e40393/asoappa.htm#ASOAG9780.
If you want to make a TCPS connection to the 11.2 database, you're going to have to include SHA1 in the list of SQLNET.CRYPTO_CHECKSUM_TYPES_CLIENT values on your 19c client, and see that the server sqlnet.ora is similarly configured. Note that use of SHA1 has been considered insecure since at least 2016.
client sqlnet.ora:
SQLNET.CRYPTO_CHECKSUM_CLIENT = REQUIRED
SQLNET.CRYPTO_CHECKSUM_TYPES_CLIENT = (SHA256, SHA1)
11gR2 server sqlnet.ora:
SQLNET.ENCRYPTION_SERVER = REQUIRED
SQLNET.ENCRYPTION_TYPES_SERVER = AES256
SQLNET.CRYPTO_CHECKSUM_SERVER = REQUIRED
SQLNET.CRYPTO_CHECKSUM_TYPES_SERVER = SHA1
Also note that per Oracle Support Doc ID 207303.1 your 11gR2 database must be at least version 11.2.0.3 or 11.2.0.4 to support a 19c client. Previous releases (e.g. 11.2.0.1) do not support the 19c client at all.
Finally my DBAs pitch in. Client sqlnet.ora is updated as below and no change to 11gR2 server sqlnet.ora:
NAMES.DIRECTORY_PATH=(EZCONNECT,TNSNAMES)
SQLNET.ENCRYPTION_CLIENT = REQUIRED
SQLNET.ENCRYPTION_TYPES_CLIENT = (AES256,RC4_256,AES192,3DES168,AES128,RC4_128,3DES112,RC4_56,DES,RC4_40,DES40)
SQLNET.CRYPTO_CHECKSUM_CLIENT = REQUIRED
SQLNET.CRYPTO_CHECKSUM_TYPES_CLIENT =(SHA256,MD5)
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
Thank you #pmdba for your guidance.

Import Database IMPDP - Different Versions

We are having oracle installed in 2 different servers.
Server 1: Oracle Version Details
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production"
TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
Server 2: Oracle Version Details
Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE 11.2.0.1.0 Production"
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
I need to import a database backup from Server 1 to Server 2. I have tried this.
Export From Server 1:
EXPDP Username/Password#xe DIRECTORY=CUSTOM_DIR SCHEMAS=PRICE DUMPFILE=PRICE.DMP
Import To Server 2:
IMPDP Username/Password#\"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=Test)(PORT=1500)))(CONNECT_DATA=(SID=TESTSID)))\" DIRECTORY=CUSTOM_DIR DUMPFILE=TEST.DMP TABLE_EXISTS_ACTION=REPLACE LOGFILE=TEST.LOG
While importing, i am getting the exception as,
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
UDI-00018: Data Pump client is incompatible with database version 11.2.0.1.0
Is that not possible to import the backups between different versions.?
Yes, it is possible. You need to supply the "version" parameter on the export, and specify 11.2.0.1. This will instruct expdp to create a dmp file that is compatible with that version. See expdp command reference
I tried to use Oracle Database 12g Data Pump to import dump file inside a Oracle 11g Database. The return i got was UDI-00018: Data Pump client is incompatible with database version 11.2.0.4.0 .
The cause is: Two Oracle Homes in different versions, and the expdp/impdp called is wrong (verify path variable).
This may be occuring with you. You have another $ORACLE_HOME in your environment, and the data pump called is from this environment. Verify your .bash_profile or .profile files and set the correct environment.

oracle instantclient 12c EZCONNECT in Powershell Prompt for password

I have installed instantclient 12c x86 on Windows 8.1
I am able to connect from cmd.exe:
C:\Users\vagrant>sqlplus user#\"hostname:1521/SERVICE_NAME\"
SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 3 06:22:31 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management,
OLAP,
Data Mining and Real Application Testing options
SQL>
Now when I try the same from Powershell:
I want to be prompted for password. It does not work.
PS C:\Users\vagrant> sqlplus user#\"hostname:1521/SERVICE_NAME\"
SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 3 06:30:12 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Enter user-name:
Here I provide my password and it works
PS C:\Users\vagrant>sqlplus user/password#hostname:1521/SERVICE_NAME
SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 3 06:24:48 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL>
What is the correct syntax for being prompted for password logging in with sqlplus from Powershell?

Connect to Oracle as SYSDBA using OCI or SQL*Plus, from client machine

I'm using Instant-Client 12.1.0.2.0, connecting to a 12.1.0.1.0 (Linux) server, in Multi-Tenant configuration.
Using either:
SQL*Plus
OCILogon2
OCIServerAttach + OCISessionBegin(OCI_RDBMS credentials, OCI_DEFAULT mode)
I can connect (using EZCONNECT, no environment variables at all) from a client machine to a PDB on the server, using SYSTEM. E.g.
c:\>sqlplus system#'//host/pdb12c_1.domain.net'
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 20 11:14:10 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
Last Successful login time: Tue Oct 20 2015 11:10:10 +02:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> quit
But as soon as I add as SYSDBA to the command line, it fails:
c:\>sqlplus system#'//host/pdb12c_1.domain.net' as SYSDBA
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 20 11:14:22 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
ERROR:
ORA-01017: invalid username/password; logon denied
I've modified my OCI application to use OCI_SYSDBA as the mode to OCISessionBegin, and it fails the same way. I've tried SYSOPER with both SQL*Plus and my OCI client app, and it also fails the same way.
What am I missing? What kind of restriction are placed on connection that want to gain SYSDBA? Is this mode impossible from a client machine? Or is that because I connect to a PDB instead of the CDB?
I'd appreciate some insights. Thanks.
PS: yes, I double and triple checked I typed the password in correctly
c:>sqlplus system#'//host/pdb12c_1.domain.net' as SYSDBA
You are using SYSTEM user which is incorrect. You need to use SYS.
For example,
C:\Users\lkb>sqlplus sys#pdborcl as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Tue Oct 20 15:11:25 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>

Oracle: Remotely import using Impdp with DB link

I'm trying to import a schema using data pump. Here's my problem: I can only access the impdp utility on the source DB server, but it's version 11.1, and the target DB version is 11.2, so if I run the import, I got an error:
UDI-00018: Data Pump client is incompatible with database version 11.01.00.06.00
I want to work around this by using my laptop, installed with the Oracle express version 11.2, same version as the target DB, by using this command:
impdp username/password#targetDB directory=data_pump_dir network_link=sourceDB schemas=EMP
In this command, targetDB is a public db link created on my local oracle, and the same record has been added to tnsnames.ora; sourceDB is a public db link created in the target DB, pointing to the source DB.
But I got this error:
Connected to: Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
ORA-39001: invalid argument value
ORA-39200: Link name "sourceDB" is invalid.
ORA-12170: TNS:Connect timeout occurred
The source DB version is:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for 64-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
The target DB version is:
Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
My local DB version is:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
So what did I do wrong?
Is there a way to import from the source to target?
It looks like you cannot access your local database remotely:
In order to avoid
ORA-12170: TNS:Connect timeout occurred
Is to make sure that you are able to connect to the remote database.
I advise you start making sure it works with a simple query accessing the db-link:
SQL> select * from dual#sourceDB;
Another solution
Another solution to your problem is to specify the target version of the export file at the time you export it, e.g. with:
version=11.1

Resources