How to connect to Oracle database using Sys user?

How to connect to Oracle database using Sys user?

In my previous article I have given multiple SQL queries. In this article I would like to give you the answer of the important question. How to connect to Oracle database using sys user? I would like to give you multiple examples of the how to connect to Oracle database using sys user. Before we start, we must need to know that there are container database and pluggable databases in oracle. The container database is the key database of Oracle. When user first time logs in to database, he or she will be logged in to the container database. As per the oracle architecture the Inside container database there are pluggable databases. Those are basically used in our application development and management.

What you will find in this article?

1.How to connect to the oracle using the SQL PLUS?

2.How to connect to the oracle using in SQL developer?

3.How to connect to HR schema in oracle?

I would like to explain the multiple steps to connect to the Oracle database in different environments.

Connecting to Oracle using SQL PLUS:

The SQL plus interface is been used by mostly DBA rather than developer. The PL SQL or oracle developers will use the Oracle SQL developer to complete the development tasks related to Oracle. But we need to know that how we can connect using sys user in SQL PLUS as well. In simple words the SQL PLUS is old fashioned command line interface which we are using to do development of oracle.  It does not contain any kind of user interface. Following are steps to connect to the Oracle using SQL PLUS :

Step 1: Open SQL Plus

Start à All Programs à Oracle Databaseà Application developmentà SQL PLUS

Step 2: Use following command and give the password of Sys user. The password is the same password which we are using at time of oracle installation.

Commands :

Enter User Name : Sys as Sysdba

Enter password :

Connected successfully.

Step 3 : Check the connection name

Show con_name;

We have now connected to root database Or you can say as container database.

Step 4 : Make changes in tnsnames.ora

The Tnsnames.ora is main configuration file to connect to the oracle database. I will explain more in connection of Oracle database with using oracle developer more regarding the same.

2.How to connect to the oracle using in SQL developer?

Step 1: Open SQL Developer

Start à All Programs à Oracle Databaseà Application developmentà SQL Developer

Step 2 : Need to check and get configuration from TNSNAMES. Ora file.

The tnsnames.ora file is most important file which is configuration file that make you connect to the database.

Path of tnsnames.ora :

 ORACLE_HOME/network/admin

The following entry is the first entry to connect to the Oracle container database.

The ORCL is the same name as database name and HOST will be the ip address. The service name will be the same name as database name.

Step 3 :  Need to open the Oracle SQL developer and create new connection.

connect to Oracle database using Sys user

Here you need to select the ORCL. The ORCL comes from the tnsnames.ora file connection. Then you can save the connection.

The above steps will give you idea about the connection to the sys user in SQL developer.

How to connect to HR schema?

Now we have connected to container database or with using sys user. If we need to connect to HR user kindly follow the steps.

Step 1: Show con_name;

Step 2 : Select name, con_id  from v$pdbs;

Step 3 : Alter session set container=orclpdb

Step 4 : Show con_name;

Step 5 :select name, open_mode from v$pdbs;

Step 6 : alter PLUGGABLE DATABASE open;

select * from all_users;

Step 7:

ALTER USER hr identified by hr account unlock;

Step 8:

Connect to HR schema using

Conn HR identified by hr; command.

I hope that you like the article on Connect to oracle database using sys user. If you like this article or if you have any issues with the same kindly comment in comments section.