Categories: SQL Tutorials

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.

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.

Amit S

Oracle Consultant with vast experience in Oracle BI and PL/SQL Development. Amiet is the admin head of this website who contributes by preparing tutorials and articles related to database technologies. He is responsible to manage the content and front-end of the website.

Recent Posts

What is Root Cause Analysis (RCA) With real examples

In my previous article I have given details about application support engineer day to day…

1 month ago

Application Support Engineer Day to day responsibilities

In my previous articles I have given the roles and responsibilities of L1,L2 and L3…

1 month ago

What is mean by SLA ( Service Level Agreement) with Examples?

In my previous articles i have given the hierarchy of production support in real company…

1 month ago

What is Production support Hierarchy in organization?

In this article i would like to provide information about production support organization structure or…

1 month ago

What are roles and responsibilities for L3 Support Engineer?

In my previous article I have given roles for L1 and L2 support engineer with…

1 month ago

What are roles and responsibilities of L2 Engineer?

I have started this new series of how to become application support engineer. This article…

1 month ago