Monday, May 2, 2011

Different naming methods to connect oracle database

donghua@rh6:~$ tnsping orcl

TNS Ping Utility for Linux: Version 11.2.0.2.0 - Production on 02-MAY-2011 09:11:43

Copyright (c) 1997, 2010, Oracle. All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = vmxdb01.lab.dbaglobe.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (20 msec)


Directly specify complete connection descriptor

donghua@rh6:~$ sqlplus donghua/donghua@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = vmxdb01.lab.dbaglobe.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))

SQL*Plus: Release 11.2.0.2.0 Production on Mon May 2 09:12:01 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.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.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Use TNSNAMES

donghua@rh6:~$ sqlplus donghua/donghua@orcl

SQL*Plus: Release 11.2.0.2.0 Production on Mon May 2 09:13:05 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.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.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

EASY Connect

donghua@rh6:~$ sqlplus donghua/donghua@vmxdb01.lab.dbaglobe.com/orcl

SQL*Plus: Release 11.2.0.2.0 Production on Mon May 2 09:13:27 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.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.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
donghua@rh6:~$

Using TWO_TASK environment variable (Using LOCAL on Windows)

donghua@rh6:~$ export TWO_TASK=orcl
donghua@rh6:~$ sqlplus donghua/donghua

SQL*Plus: Release 11.2.0.2.0 Production on Mon May 2 09:27:57 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name,host_name from v$instance;

INSTANCE_NAME
----------------
HOST_NAME
----------------------------------------------------------------
orcl
vmxdb01.lab.dbaglobe.com


SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

No comments:

Post a Comment