Several naming methods for connecting to Oracle

Source: Internet
Author: User
Tags reserved sqlplus

People who work with Oracle use a variety of tools to connect to Oracle databases on a daily basis, such as sql*plus, PL/sql, TOAD, Sqldeveloper, and so on, listing several ways to connect to Oracle, in this case sql* Plus, for example.

1. Easy Connect Naming method

This is a very simple way, it does not need to access the Tnsnames.ora file, but to directly connect to the database.

Grammar:

CONNECT [email protected][//]host[:p ort][/[service_name][:server]][/instance_name]]enter Password:password

Examples of Use:

[[email protected] admin]$ sqlplus /nologsql*plus: release 11.2.0.1.0  production on thu jun 1 15:34:21 2017copyright  (c)  1982, 2009,  oracle.  all rights reserved.idle>conn [email protected]:1522/orclerror : ora-12504: tns:listener was not given the service_name in connect_ Dataidle>conn [email protected] ' 192.168.56.2:1522/ORCL ' enter password: connected. [email protected]>conn zx/[email protected] ' 192.168.56.2:1522/ORCL ' Connected. [Email protected]>conn zx/[email protected]:1522/orclconnected. [email protected]>conn [email protected]:1522/orclerror:ora-12504: tns:listener  Was not given the service_name in connect_datawarning: you are no  longer connected to oracle.

From the example above can be seen on the Linux platform using easy connect connection, if there is no password in the connection string, you need to enclose the connection string in quotation marks, otherwise it will error ORA-12504. You do not need to use quotation marks when the connection string contains a password.

This is a very simple way to connect to a database, and you do not need to configure any files.

For more information, refer to: http://docs.oracle.com/cd/E11882_01/network.112/e41945/naming.htm#NETAG255

2. Local Naming method

The local naming method requires that the network service name be added to the Tnsnames.ora file, and each network server corresponds to a connection descriptor. This method is also the most frequently used method in the work.

The following is an example of a connection descriptor:

Orcl= (description= (address= (protocol=tcp) (host=192.168.56.2) (port=1522)) (Connect_data= (SERVICE_NAME=ORCL)))

Tnsnames.ora files are generally stored in the $oracle_home/network/admin directory.

Use syntax:

CONNECT [Email Protected]_service_nameenter password:password

Connection examples:

[[email protected] admin]$ sqlplus/nologsql*plus:release 11.2.0.1.0 Production on Thu June 1 15:49:55 2017Copyright (c) 1  982, Oracle. All rights reserved.idle>conn [email Protected]enter password:connected. [Email protected]>

As you can see from the example above, you can connect to the corresponding database only by specifying the corresponding connection service name in the connection string.

The Tnsnames.ora can be configured using OEMs, Netmgr, NETCA.

The meaning of each parameter in Tnsnames.ora is described in detail: http://docs.oracle.com/cd/E11882_01/network.112/e10835/tnsnames.htm#NETRF007

3. Directory naming methods

Detailed reference: http://docs.oracle.com/cd/E11882_01/network.112/e41945/naming.htm#NETAG265

4. External naming method

Detailed reference: http://docs.oracle.com/cd/E11882_01/network.112/e41945/naming.htm#NETAG277


This article is from the "DBA fighting!" blog, so be sure to keep this source http://hbxztc.blog.51cto.com/1587495/1931361

Several naming methods for connecting to Oracle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.