How to connect oracle database using sql developer



Download 22.13 Kb.
Date08.01.2017
Size22.13 Kb.
#7613
How to connect oracle database using SQL developer.

Sql developer is a GUI tool to connect to any oracle database and supports development using SQL and PL/SQL. This tool is available as free download from Oracle website.

Current environment (Server)

Server OS : Oracle Linux 4.5 64bit

Database software : Oracle 10g (10.2.0.1)

No of database : 2

ORACLE_SID : ora10gdb01 & 10gdb02

ORACLE_HOME : /u01/app/oracle/product/10.2.0.1/db01


Current environment (Client)

OS : Windows 8 64bit

Client software : SQL developer version 4.0

Before connecting to database. the database & listener should be up and running on the server


[oracle@db10g ~]$ . oraenv

ORACLE_SID = [ora10gdb01] ? ora10gdb01

[oracle@db10g ~]$ echo $ORACLE_SID

ora10gdb01

[oracle@db10g ~]$ echo $ORACLE_HOME

/u01/app/oracle/product/10.2.0.1/db01

[oracle@db10g ~]$

[oracle@db10g ~]$ sqlplus / as sysdba


SQL*Plus: Release 10.2.0.1.0 - Production on Sat May 24 11:23:43 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup

ORACLE instance started.


Total System Global Area 1207959552 bytes

Fixed Size 2020352 bytes

Variable Size 318770176 bytes

Database Buffers 872415232 bytes

Redo Buffers 14753792 bytes

Database mounted.

Database opened.

SQL> !


[oracle@db10g ~]$
[oracle@db10g ~]$ lsnrctl start LISTENER
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-MAY-2014 11:37:10
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db10g.localdomain)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production

Start Date 24-MAY-2014 11:25:36

Uptime 0 days 0 hr. 11 min. 33 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF


Listener Parameter File /u01/app/oracle/product/10.2.0.1/db01/network/admin/listener.ora

Listener Log File /u01/app/oracle/product/10.2.0.1/db01/network/log/listener.log

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db10g.localdomain)(PORT=1521)))

Services Summary...

Service "10gdb02" has 1 instance(s).

Instance "10gdb02", status UNKNOWN, has 1 handler(s) for this service...

Service "ora10gdb" has 1 instance(s).

Instance "ora10gdb", status UNKNOWN, has 1 handler(s) for this service...

Service "ora10gdb01" has 1 instance(s).

Instance "ora10gdb01", status READY, has 1 handler(s) for this service...

Service "ora10gdb01XDB" has 1 instance(s).

Instance "ora10gdb01", status READY, has 1 handler(s) for this service...

Service "ora10gdb01_XPT" has 1 instance(s).

Instance "ora10gdb01", status READY, has 1 handler(s) for this service...

The command completed successfully


Download sqldeveloper-4.0.0.12.27-no-jre from oracle website and also install java on your client machine if not installed.
Extract sqldeveloper-4.0.0.12.27-no-jre and double click on sqldeveloper.exe you will see below screen while opening.





Now click on connections and on top the (+) green button to add a new connection

You will see New/Select Database connection dialogue box.

Input the details connection name you can give any name so that you can identify which database you are connecting

Username sys and the password if you want to save the password tick the box below on save password


Select connection type as basic and role as sysdba as you are connecting sys user which has dba privilege with default role it cannot connect to the database.
Hostname you can input the ip address of the oracle database server or if you have setup your host file under c:\windows\system32\drivers\etc\hosts you can put the hostname instead of ip address.

Port we have input 1521 which is the default port for oracle database

SID is your system identifier name which is ora10gdb01 in my case.
Now click on test button you should see status as success above the help button as shown below

Now click on save and close button on top or cancel button down.

Now you can write your sql query on the worksheet area as shown

Similar way we will connect to our second database. but first we will startup the instance and reload the listener

[oracle@db10g ~]$ . oraenv

ORACLE_SID = [10gdb02] ? 10gdb02

[oracle@db10g ~]$ echo $ORACLE_SID

10gdb02


[oracle@db10g ~]$ echo $ORACLE_HOME

/u01/app/oracle/product/10.2.0.1/db01

[oracle@db10g ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sat May 24 11:50:08 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.

SQL> startup

ORACLE instance started.
Total System Global Area 1207959552 bytes

Fixed Size 2020352 bytes

Variable Size 318770176 bytes

Database Buffers 872415232 bytes

Redo Buffers 14753792 bytes

Database mounted.

Database opened.

SQL> ! lsnrctl reload LISTENER


LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-MAY-2014 11:50:39
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db10g.localdomain)(PORT=1521)))

The command completed successfully


SQL> ! lsnrctl status LISTENER
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-MAY-2014 11:52:02
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db10g.localdomain)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production

Start Date 24-MAY-2014 11:25:36

Uptime 0 days 0 hr. 26 min. 25 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF


Listener Parameter File /u01/app/oracle/product/10.2.0.1/db01/network/admin/listener.ora

Listener Log File /u01/app/oracle/product/10.2.0.1/db01/network/log/listener.log

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db10g.localdomain)(PORT=1521)))

Services Summary...

Service "10gdb02" has 2 instance(s).

Instance "10gdb02", status UNKNOWN, has 1 handler(s) for this service...

Instance "10gdb02", status READY, has 1 handler(s) for this service...

Service "10gdb02_XPT" has 1 instance(s).

Instance "10gdb02", status READY, has 1 handler(s) for this service...

Service "ora10gdb" has 1 instance(s).

Instance "ora10gdb", status UNKNOWN, has 1 handler(s) for this service...

Service "ora10gdb01" has 1 instance(s).

Instance "ora10gdb01", status READY, has 1 handler(s) for this service...

Service "ora10gdb01XDB" has 1 instance(s).

Instance "ora10gdb01", status READY, has 1 handler(s) for this service...

Service "ora10gdb01_XPT" has 1 instance(s).

Instance "ora10gdb01", status READY, has 1 handler(s) for this service...

Service "ora10gdb02XDB" has 1 instance(s).

Instance "10gdb02", status READY, has 1 handler(s) for this service...

The command completed successfully

Here I am getting error ORA-01031 insufficient privileges this is because I have not created password file for my second database so we will create our password file as below
SQL> ! orapwd file=orapw10gdb02 password= entries=5
[oracle@db10g ~]$ cd $ORACLE_HOME/dbs
[oracle@db10g dbs]$ ll

total 80


-rw-rw---- 1 oracle oinstall 1552 May 15 16:28 hc_10gdb01.dat

-rw-rw---- 1 oracle oinstall 1552 May 12 21:07 hc_10gdb02.dat

-rw-r----- 1 oracle oinstall 1552 May 6 20:30 hc_ora10gdb01.dat

-rw-rw---- 1 oracle oinstall 1552 May 12 20:49 hc_ora10gdb02.dat

-rw-r--r-- 1 oracle oinstall 1350 May 15 17:07 init10gdb02.ora

-rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora

-rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora

-rw-r--r-- 1 oracle oinstall 1285 May 18 16:52 initora10gdb01.ora

-rw-rw---- 1 oracle oinstall 24 May 12 20:49 lk10GDB02

-rw-r----- 1 oracle oinstall 24 May 6 20:30 lkORA10GDB01

-rw-r--r-- 1 oracle oinstall 1350 May 15 16:34 oldinit10gdb02.ora

-rw-r----- 1 oracle oinstall 2048 May 24 19:24 orapw10gdb02

-rw-r----- 1 oracle oinstall 1536 May 24 12:08 orapwora10gdb01

-rw-r----- 1 oracle oinstall 3584 May 24 12:05 spfile10gdb02.ora

-rw-r----- 1 oracle oinstall 3584 May 24 11:23 spfileora10gdb01.ora


Now you can connect to the database as shown below

Cheers and happy learning

If you have any queries please write to me at sunil@sunilthetechfreak.com

Download 22.13 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page