How to change default Oracle 11g to 19c in cli Windows 10? - database

How to change default Oracle 11g to 19c in cli Windows 10?
I have 2 Oracle db releases on my Windows 10: 11g & 19c.
When I enter cmd line (or any shell), type sqlplus I am by defalut connected to 11g release.
I would like to change default db in cmd to 19c. How can I do that?

We will follow the PATH variable in the absence of anything else, eg
c:\>set PATH=C:\oracle\product\19\bin;%PATH%
c:\>sqlplus /nolog
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Feb 16 18:32:44 2021
Version 19.8.0.0.0
Copyright (c) 1982, 2020, Oracle. All rights reserved.
c:\>set PATH=C:\oracle\product\18\bin;%PATH%
c:\>sqlplus /nolog
SQL*Plus: Release 18.0.0.0.0 - Production on Tue Feb 16 18:33:08 2021
Version 18.6.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Then set your ORACLE_SID or connect via a service as already mentioned

Usually we use TNSNAMES.ORA file which contains "aliases" to databases we access. Then, while connecting to a desired database, we specify its alias:
sqlplus scott/tiger#ora11g
or
sqlplus mike/lion#ora19c
Although you may have access to only 2 databases, my TNSNAMES.ORA contains entries for 55 of them. What I'm trying to say is that you may consider "one" database "default", but as the time goes by, that "default" will either change or will be mostly useless as you'll connect to different databases on a daily bases. Therefore, check your TNSNAMES.ORA, specify its alias along with username/password and ... that's it.

Related

Error in converting batch to exe using IExpress

I am Converting my batch file to .exe file i have added .sql file and jpg file
i have successfully created package but when i am run this package i am getting an error like this
C:\Users\DEVELO~1\AppData\Local\Temp\IXP001.TMP>set /p dbnm=ENTER THE DATABASE SERVICE NAME
ENTER THE DATABASE SERVICE NAME UAT
SQL*Plus: Release 10.2.0.3.0 - Production on Thu Dec 20 15:16:01 2018
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SP2-0310: unable to open file "C:\Users\DEVELO~1\AppData\Local\Temp\IXP001.TMP\\harsh.sql"
SQL> SP2-0734: unknown command beginning "ECHO is on..." - rest of line ignored.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Press any key to continue . . .
my batch file path is D:\harsh
need help any answer?

Oracle expdp compatibility issue

I have an Enterprise Oracle Database 12.2.0.1.0 installed. The output of 'show compatible' is 12.2.0.1.4.
When I try to run EXPDP with the correct credentials, I get the following error:
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
ORA-39001: invalid argument value
ORA-39021: Database compatibility version 12.2.0.1.4 is not supported.
After which EXPDP exists.
Should EXPDP's version be aligned with the 'compatible' parameter?

Oracle Express: Getting ORA-12154 error when trying to connect using SQL Plus

My computer's operating system is Windows 7 64-bit. I just downloaded and install Oracle Express 11g Windows 64-bit. During installation it ask me to set password for both the SYS and the SYSTEM database accounts which I provide as P#ssword1. Everything went ok during installation.
Now I want to connect using SQL Plus. So I click on All Programs --> Oracle Database 11g Express Edition --> Run SQL Command Line to open SQL Plus.
There I type in connect system/P#ssword1 and press Enter key. But I get this error message: ORA-12154: TNS:could not resolve the connect identifier specified
SQL*Plus: Release 11.2.0.2.0 Production on Wed Jan 18 22:19:11 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
SQL> connect system/P#ssword1 ERROR: ORA-12154: TNS:could not resolve
the connect identifier specified
SQL>
Why I cannot connect?
Thanks
Since you are using P#ssword1 as the password
Can you try the following for connecting to DB instance through SQL*PLUS?
connect system/"P#ssword1"
The reason for Oracle to throw the error is that it treats ssword1 (P#ssword1) as the connect identifier.

Exporting Oracle 11G R2 dump file

I am new to oracle and need to start a project. For this I need to restore a dump file. I tried all the methods, but not getting success. Dump file is from Oracle 11 G R2 and same version is installed on my desktop Windows PC. Steps followed are as below:
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.
C:\Users\kartikeyap>SQLplus
SQL*Plus: Release 11.2.0.1.0 Production on Thu Sep 8 23:38:58 2016
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Enter user-name: SYSTEM
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create tablespace csiprod datafile 'csiprod' size 3000M
2 ;
Tablespace created.
SQL> create user csitest identified by csitest default tablespace csiprod temporary tablespace temp;
User created.
SQL> grant all privileges to csitest;
Grant succeeded.
SQL> create or replace directory c_drive as 'C:/';
Directory created.
SQL> grant read,write on directory c_drive to csitest;
Grant succeeded.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
C:\Users\kartikeyap>cd\
C:\>impdp SYSTEM/diya2478 schemas=csitest directory=c_drive dumpfile=csiprod.dmp;
But every time I am getting error below:
Import: Release 11.2.0.1.0 - Production on Thu Sep 8 23:44:50 2016
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31640: unable to open dump file "C:/csiprod.dmp;" for read
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.
It will be of great help if someone take a look and get this resolved for me.

how to connect to an oracle database from unix

I am trying to connect to an oracle database from my unix machine. I am new to script writing in general. I know how to browse round unix and have written basic scripts ( read / display ) and execute them with bash command. Also I know how to view the variables in unix ( user and system). Could you tell me what i need to do to connect to an oracle database? do I use the sqlplus command? are there any variables I have to set before that?
Could you tell me what i need to do to connect to an oracle database? do I use the sqlplus command?
Well, yes of course, you need to use SQL*Plus. However, before that, you need to make sure of few things:
export ORACLE_HOME variable
For example,
export ORACLE_HOME=/u01/app/oracle/product/11.2.0
export PATH variable
For example,
export PATH=$PATH:$ORACLE_HOME/bin
export SID
For example,
export ORACLE_SID="your database service name"
Make sure you have the tnsnames.ora configured properly
Make sure you have the listener up and running and is listening to the correct port.
You should be able to connect to the database as:
sqlplus username/password#sid
Set ORACLE_HOME & ORACLE_SID environment variable.
Then use
sqlplus username#ORACLE_SID
Make sure you've exported all the necessary Oracle variable in your unix user path environment as below:
ORACLE_BASE=/home/oracle/app; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1/; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
PATH=$ORACLE_HOME/bin:$HOME/bin:$PATH; export PATH
And Make sure tnsnames.ora file is configured properly and listener should be up and running as below.
[oracle#OLE1 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ole1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
[oracle#OLE1 ~]$ tnsping orcl
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 12-JUL-2017 23:12:35
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ole1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (20 msec)
[oracle#OLE1 ~]$
[oracle#OLE1 ~]$ cat /etc/hosts
127.0.0.1 localhost
::1 localhost
192.168.244.128 ole1
[oracle#OLE1 ~]$
Now you've multiple ways to connect database from unix command prompt.
[oracle#OLE1 ~]$ sqlplus scott/tiger
[oracle#OLE1 ~]$ sqlplus scott/tiger#orcl
[oracle#OLE1 ~]$ sqlplus scott/tiger#192.168.244.128:1521/orcl
[oracle#OLE1 ~]$ sqlplus scott/tiger#//192.168.244.128:1521/orcl
[oracle#OLE1 ~]$ sqlplus "scott/tiger#(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ole1)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))"
[oracle#OLE1 ~]$ sqlplus scott/tiger
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 12 23:29:30 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle#OLE1 ~]$ sqlplus scott/tiger#orcl
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 12 23:30:00 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected
[oracle#OLE1 ~]$
[oracle#OLE1 ~]$ sqlplus scott/tiger#192.168.244.128:1521/orcl
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 12 23:30:00 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected
[oracle#OLE1 ~]$
[oracle#OLE1 ~]$ sqlplus scott/tiger#//192.168.244.128:1521/orcl
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 12 23:30:00 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected
[oracle#OLE1 ~]$
[oracle#OLE1 ~]$ sqlplus "scott/tiger#(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ole1)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))"
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 13 12:30:23 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
SQL> show user
USER is "SCOTT"
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle#OLE1 ~]$

Resources