How can we connect to the database?no_redirect=1

­Oracle Database XE supports connections between the SQL Command Line (SQL*Plus) and the database either locally, or remotely over a TCP/IP network. The method that you use to connect to Oracle Database XE with the SQL Command Line depends on whether you are initiating a local connection or a remote connection. Local and remote connections are explained in the following sections:

About Local Connections

Connecting locally means running the SQL Command Line (or any other Oracle command-line utility) on the same host computer where Oracle Database XE is installed (the "Oracle Database XE host computer") and then initiating a database connection from the SQL Command Line (or other utility), or using SQL Developer to connect as a local database user. To connect locally, you must supply only a database user name and password. For example, Figure 3-1 shows a user connecting locally with the SQL Command Line and entering a command that supplies the user name and password .

Environment Variables

Before making a local connection on Linux, you must set environment variables. See "Setting Environment Variables" for more information.

Note:

Logging in to the Oracle Database XE host computer with an (or ) session and then starting the SQL Command Line (or other Oracle command-line utility) is considered a local connection, even though you start the (or ) application on a remote computer.

About Remote Connections

Connecting remotely means running the SQL Command Line (or any other Oracle command-line utility) on a computer other than the Oracle Database XE host computer, and then initiating a database connection from the SQL Command Line (or other utility) over the network.

Oracle Client Software

The remote computer must have Oracle client software installed. It is through Oracle client software that Oracle command-line utilities (and your applications) connect to the database. Oracle Database XE accepts connections from all of the following types of Oracle client software:

  • Oracle Database Express Edition Client (Oracle Database XE)

    When you install Oracle Database XE, Oracle Database Express Edition Client is also installed on the same computer. You can install Oracle Database XE separately on remote computers. It is available at

  • Instant Client

    Instant Client is available at

http://www.oracle.com/technetwork/database/features/instant-client/index-100365.html
  • Oracle client software for Oracle Database Enterprise Edition or Standard Edition (all supported releases of Oracle Database)

All Oracle client software includes Oracle Net, which is the Oracle network software that enables client applications on one computer to connect to databases on another computer over a network.

Connect Strings

To connect remotely, you must supply not just a user name and password, but a complete Oracle Net connect string. In addition to the database user name and password, a connect string includes a host name or host IP address, an optional TCP port number, and an optional database service name. These additional parameters are required to help Oracle Net find the right host computer and connect to Oracle Database XE. An Oracle Net connect string has the following format:

username/[email protected][//]host[:port][/service_name]

where:

  • is optional

  • is the host name or IP address of the computer that is running Oracle Database XE

  • (optional) is the TCP port number on which the Oracle Net listener is listening. If not specified, the default port number 1521 is assumed.

  • (optional) is the name of the database service to which to connect. For Oracle Database XE, the service name is . If is omitted, Oracle Database XE Client appends a request for the default database service, which is configured during installation as .

Note:

Only Oracle Database XE supports the notion of a default database service. If you connect remotely from any Oracle client software other than Oracle Database XE, you must include the service name.

For example, Figure 3-2 shows a user connecting remotely with the SQL Command Line and entering a command that includes a connect string that supplies: the user name , the password , and the host name . This connect string connects to the default database service () on the default port ().

Environment Variables

Before making a remote connection from Linux, you must set environment variables. See "Setting Environment Variables" for more information.

Remote Connection Examples

In the following examples of the SQL Command Line commands, Oracle Database XE is running on the host computer .

Example 1 This example initiates a remote connection from Oracle Database XE, using the default port number.

CONNECT system/[email protected]

Example 2 This example initiates a remote connection from Oracle Database XE, using a nondefault port number (1522):

CONNECT system/[email protected]:1522

Example 3 This example initiates a remote connection using the default port number, and includes the optional service name.

CONNECT system/[email protected]/XE