Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Several naming ways to connect to Oracle

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

People engaged in Oracle-related work use a variety of tools to connect to Oracle databases every day, such as SQL*Plus, PL/SQL, TOAD, SQLDeveloper, and so on. Here are several ways to connect to Oracle. In this case, SQL*Plus is used as an 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.

Syntax:

CONNECT username@ [/ /] host [: port] [/ [service_name] [: server]] [/ instance_name]] Enter password: password

Examples of use:

[oracle@rhel6 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 zx@192.168.56.2:1522/orclERROR:ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATAidle > conn zx@'192.168.56.2:1522/orcl'Enter password: Connected.zx@ORCL > conn zx/zx@'192.168.56.2:1522/orcl'Connected.zx@ORCL > conn zx/zx@192.168.56.2:1522/orclConnected.zx@ORCL > conn zx@192.168.56.2:1522/orclERROR:ORA-12504: TNS : listener was not given the SERVICE_NAME in CONNECT_DATAWarning: You are no longer connected to ORACLE.

You can see from the above example that when using Easy Connect connection on Linux platform, if there is no password in the connection string, you need to enclose the connection string in quotation marks, otherwise an error ORA-12504 will be reported. When the connection string contains a password, you do not need to use quotation marks.

This is a very simple way to connect to the database and does not need to configure any files.

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

2. Naming method of Local

Local naming requires adding the network service name to the tnsnames.ora file, with each network server corresponding to a connection descriptor. This method is also the most commonly used method at work.

Here is an example of a connection descriptor:

Orcl= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=192.168.56.2) (PORT=1522)) (CONNECT_DATA= (SERVICE_NAME=orcl)

The tnsnames.ora file is typically stored in the $ORACLE_HOME/network/admin directory.

Use syntax:

CONNECT username@net_service_nameEnter password: password

Connection example:

[oracle@rhel6 admin] $sqlplus / nologSQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 1 15:49:55 2017Copyright (c) 1982, 2009, Oracle. All rights reserved.idle > conn zx@orclEnter password: Connected.zx@ORCL >

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

Tnsnames.ora can be configured using OEM, netmgr, and netca.

For more information on the meaning of the parameters in tnsnames.ora, please see: http://docs.oracle.com/cd/E11882_01/network.112/e10835/tnsnames.htm#NETRF007

3. Naming method of Directory

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report