| Oracle® Database Express Edition 2 Day Developer's Guide 11g Release 2 (11.2) Part Number E18147-07 |
|
|
PDF · Mobi · ePub |
You can connect to Oracle Database Express Edition (Oracle Database XE) only through a client program, such as SQL*Plus or SQL Developer.
This chapter contains the following sections:
SQL*Plus is a client program with which you can access Oracle Database XE. This section shows how to start SQL*Plus and connect to Oracle Database XE.
To connect to Oracle Database XE from SQL*Plus:
If you are on a Windows system, display a Windows command prompt.
At the command prompt, type sqlplus and press the key Enter.
SQL*Plus starts and prompts you for your user name.
Type your user name and press the key Enter.
SQL*Plus prompts you for your password.
Type your password and press the key Enter.
Note:
For security, your password is not visible on your screen.The system connects you to an Oracle Database XE instance.
You are in the SQL*Plus environment. At the SQL> prompt, you can enter and run SQL*Plus commands, SQL statements, PL/SQL statements, and operating system commands.
To exit SQL*Plus, type exit and press the key Enter.
Note:
Exiting SQL*Plus ends the SQL*Plus session, but does not shut down the Oracle Database XE instance.Example 2-1 starts SQL*Plus, connects to Oracle Database XE, runs a SQL SELECT statement, and exits SQL*Plus. User input is bold.
Example 2-1 Connecting to Oracle Database from SQL*Plus
> sqlplus SQL*Plus: Release 11.2.0.2.0 Production on Thu Feb 17 09:48:30 2011 Copyright (c) 1982, 2010, Oracle. All rights reserved. Enter user-name: your_user_name Enter password: your_password Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta SQL> select count(*) from employees; COUNT(*) ---------- 107 SQL> exit Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta >
See Also:
"About SQL*Plus" for a brief description of SQL*Plus
SQL*Plus User's Guide and Reference for more information about starting SQL*Plus and connecting to Oracle Database XE
SQL Developer is a client program with which you can access Oracle Database XE. With Oracle Database XE 11g Release 2 (11.2), you must use SQL Developer version 3.0. This section assumes that SQL Developer is installed on your system, and shows how to start it and connect to Oracle Database XE. If SQL Developer is not installed on your system, see Oracle Database SQL Developer User's Guide for installation instructions.
Note:
For the following procedure:To connect to Oracle Database XE from SQL Developer:
For instructions, see Oracle Database SQL Developer User's Guide.
If this is the first time you have started SQL Developer on your system, you are prompted to enter the full path to java.exe (for example, C:\jdk1.5.0\bin\java.exe). Either type the full path after the prompt or browse to it, and then press the key Enter.
The Oracle SQL Developer window opens.
In the navigation frame of the window, click Connections.
The Connections pane appears.
In the Connections pane, click the icon New Connection.
The New/Select Database Connection window opens.
In the New/Select Database Connection window, type the appropriate values in the fields Connection Name, Username, and Password.
For security, the password characters that you type appear as asterisks.
Near the Password field is the check box Save Password. By default, it is deselected. Oracle recommends accepting the default.
In the New/Select Database Connection window, click the tab Oracle.
The Oracle pane appears.
For Connection Type, accept the default (Basic).
For Role, accept the default.
In the fields Hostname and Port, either accept the defaults or type the appropriate values.
Select the option SID.
In the SID field, type accept the default (xe).
In the New/Select Database Connection window, click the button Test.
The connection is tested. If the connection succeeds, the Status indicator changes from blank to Success.

If the test succeeded, click the button Connect.
The New/Select Database Connection window closes. The Connections pane shows the connection whose name you entered in the Connection Name field in step 4.
You are in the SQL Developer environment.
To exit SQL Developer, select Exit from the File menu.
Note:
Exiting SQL Developer ends the SQL Developer session, but does not shut down the Oracle Database XE instance. The next time you start SQL Developer, the connection you created using the preceding procedure still exists. SQL Developer prompts you for the password that you supplied in step 4 (unless you selected the check box Save Password).See Also:
"Connecting to Oracle Database XE as User HR from SQL Developer"
"About SQL Developer" for a brief description of SQL Developer
Oracle Database SQL Developer User's Guide for more information about using SQL Developer to create connections to Oracle Database XE
This section shows how to unlock the HR account and connect to Oracle Database XE as the user HR, who owns the HR sample schema that the examples and tutorials in this document use.
To do the tutorials and examples in this document, and create the sample application, you must connect to Oracle Database XE as the user HR from SQL Developer. The HR sample schema is the development environment for the sample application.
Topics:
By default, when the HR schema is installed, the HR account is locked and its password is expired. You can connect to Oracle Database as the user HR only if the HR account is unlocked.
Note:
For the following procedure, you need the name and password of a user who has theALTER USER system privilege (for example, SYSTEM).To unlock the HR account and reset its password:
Using SQL*Plus, connect to Oracle Database XE as a user with the ALTER USER system privilege.
At the SQL> prompt, unlock the HR account and reset its password:
Caution:
Choose a secure password. For guidelines for securing passwords, see Oracle Database Security Guide.ALTER USER HR ACCOUNT UNLOCK IDENTIFIED BY password;
The system responds:
User altered
The HR account is unlocked and its password is password.
Now you can connect to Oracle Database XE as user HR with the password password.
See Also:
Oracle Database 2 Day + Security Guide for information about predefined user accounts provided by Oracle Database XE, including HR
Oracle Database SQL Developer User's Guide for information about accessing SQL*Plus within SQL Developer
Oracle Database Express Edition 2 Day DBA for information about using Enterprise Manager to unlock user accounts
This section shows how to connect to Oracle Database XE as the user HR from SQL*Plus, if the HR account is unlocked.
To connect to Oracle Database XE as user HR from SQL*Plus:
Note:
For this task, you need the password for theHR account.If you are connected to Oracle Database XE, close your current connection.
Follow the directions in "Connecting to Oracle Database XE from SQL*Plus", entering the user name HR at step 3 and the password for the HR account at step 4.
You are now connected to Oracle Database XE as the user HR.
See Also:
SQL*Plus User's Guide and Reference for an example of using SQL*Plus to create anHR connectionThis section shows how to connect to Oracle Database XE as the user HR from SQL Developer, if the HR account is unlocked.
Note:
For the following procedure, you need the password for theHR account.To connect to Oracle Database XE as user HR from SQL Developer:
Follow the directions in "Connecting to Oracle Database XE from SQL Developer", entering the following values at steps 4:
For Connection Name, enter hr_conn.
(You can enter a different name, but the tutorials in this document assume that you named the connection hr_conn.)
For Username, enter HR.
For Password, enter the password for the HR account.
You are now connected to Oracle Database XE as the user HR.