SQL*Plus® User's Guide and Reference Release 10.1 Part Number B12170-01 |
|
|
View PDF |
These instructions are to enable you to login and connect to a database after you have installed SQL*Plus. You can connect to the default database you created during installation, or to another existing Oracle database.
SQL*Plus on the Oracle Technology Network at http://otn.oracle.com/tech/sql_plus/
.
SQL*Plus Discussion Forum at http://www.oracle.com/forums/
.
Oracle Documentation Library at http://otn.oracle.com/documentation
.
SQL*Plus Product and Documentation feedback by emailing sqlplus@oracle.com.
SQL*Plus is an interactive and batch query tool that is installed with every Oracle Database Server or Client installation. It has a command-line user interface, a Windows Graphical User Interface (GUI) and the iSQL*Plus web-based user interface.
SQL*Plus has its own commands and environment, and it provides access to the Oracle Database. It enables you to enter and execute SQL, PL/SQL, SQL*Plus and operating system commands to perform the following:
Format, perform calculations on, store, and print from query results
Examine table and object definitions
Develop and run batch scripts
Perform database administration
You can use SQL*Plus to generate reports interactively, to generate reports as batch processes, and to output the results to text file, to screen, or to HTML file for browsing on the Internet. You can generate reports dynamically using the HTML output facility of SQL*Plus, or using the dynamic reporting capability of iSQL*Plus to run a script from a web page.
What is necessary before you can run SQL*Plus or iSQL*Plus?
Install Oracle Database (or Oracle Client for the command-line SQL*Plus or Windows GUI interfaces only). See the Oracle Database Installation Guide for your operating system available at http://otn.oracle.com/documentation/
.
Obtain an Oracle Database login username and password during installation or from your Database Administrator. See Login Username and Password.
Ensure a sample database is installed and that you have a login username and password for it during Oracle Database installation. See Sample Schemas and SQL*Plus.
Create a default database during installation or obtain the connection identifier for the Oracle Database you want to connect to from your Database Administrator. See Connecting to a Database.
Ensure the database you want to connect to is started. See the STARTUP command.
If using iSQL*Plus, ensure that you have the URL for the Application Server you want to connect to, and that the Application Server is available and running. See Starting the iSQL*Plus Application Server, and Testing if the iSQL*Plus Application Server is Running.
The SQL*Plus executable is usually installed in $ORACLE_HOME/bin, which is usually included in your operating system PATH environment variable. You may need to change directory to the $ORACLE_HOME/bin directory to start SQL*Plus.
Open a UNIX or a Windows terminal and enter the SQL*Plus command:
sqlplus
When prompted, enter your Oracle Database username and password. If you do not know your Oracle Database username and password, ask your Database Administrator.
Alternatively, enter the SQL*Plus command in the form:
sqlplus username/password
To hide your password, enter the SQL*Plus command in the form:
sqlplus username
You will be prompted to enter your password.
SQL*Plus starts and connects to the default database.
Now you can start entering and executing SQL, PL/SQL and SQL*Plus statements and commands at the SQL> prompt.
Open a UNIX or a Windows terminal and enter the SQL*Plus command:
sqlplus username/password@connect_identifier
To hide your password, enter the SQL*Plus command in the form:
sqlplus username@connect_identifier
You will be prompted to enter your password.
Click Start > Programs > Oracle-OraHomeName > Application Development > SQL Plus.
Alternatively, open a Windows terminal and enter the SQL*Plus command:
sqlplusw
The SQL*Plus Windows GUI opens and the Log On dialog is displayed.
Enter your Oracle Database username and password in the Log On dialog. If you do not know your Oracle Database username and password, ask your Database Administrator.
Leave the Host String field blank to connect to the default database. Enter a connection identifier for the database you want to connect to in the Host String field. You can connect to Oracle8i, Oracle9i and Oracle Database 10g databases.
Click OK. SQL*Plus starts and connects to the database.
Now you can start entering and executing SQL, PL/SQL and SQL*Plus statements and commands at the SQL> prompt.
The iSQL*Plus Application Server is started during Oracle Database installation. It must be running to enable web-based iSQL*Plus sessions. See Starting the iSQL*Plus Application Server.
Enter the iSQL*Plus URL in your web browser's Location or Address field. The iSQL*Plus URL looks like:
http://machine_name.domain:port/isqlplus
Press Enter to go to the URL. The iSQL*Plus Login screen is displayed in your web browser.
Enter your Oracle Database username and password in the Username and Password fields. If you do not know your Oracle Database username and password, ask your Database Administrator.
Leave the Connection Identifier field blank to connect to the default database.
Enter an Oracle Database connection identifier in the Connection Identifier field to connect to a database other than the default. You can connect to Oracle8i, Oracle9i and Oracle Database 10g databases.
If restricted database access has been configured, the Connection Identifier field is a dropdown list of available databases to select.
Click Login to connect to the database. The iSQL*Plus Workspace is displayed in your web browser.
Now you can start entering and executing SQL, PL/SQL and SQL*Plus statements and commands in the Workspace.
From an existing Windows GUI or command-line session, enter a CONNECT command in the form:
SQL> connect username/password@connect_identifier
To hide your password, enter the CONNECT command in the form:
SQL> connect username@connect_identifier
You will be prompted to enter your password.
From an existing iSQL*Plus session, enter a CONNECT command in the form:
connect username/password@connect_identifier
If you do not enter a password, iSQL*Plus prompts you to enter one.
Sample schemas are included with the Oracle Database. Examples in this guide use the EMP_DETAILS_VIEW view of the Human Resources (HR) sample schema. This schema contains personnel records for a fictitious company.
For more information about the sample schemas, see the Oracle Database Sample Schemas guide.
The Human Resources (HR) Sample Schema may be installed as part of the default Oracle Database installation. The HR account is locked by default.
You need to unlock the HR account before you can use the HR sample schema. To unlock the HR account, log in as the SYSTEM user and enter the following command, where password is the password you want to define for the user HR:
ALTER USER HR IDENTIFIED BY password ACCOUNT UNLOCK;
To describe a database object using iSQL*Plus, for example, column details for EMP_DETAILS_VIEW, enter a DESCRIBE command like:
DESCRIBE EMP_DETAILS_VIEW
which produces the following output:
To rename the column headings, and to select data from the HR sample schema view, EMP_DETAILS_VIEW, enter
COLUMN FIRST_NAME HEADING "First Name" COLUMN LAST_NAME HEADING "Family Name" SELECT FIRST_NAME, LAST_NAME FROM EMP_DETAILS_VIEW WHERE LAST_NAME LIKE 'K%';
which produces the following output:
It is recommended that you always use the Logout icon to exit iSQL*Plus to free up system and server resources.
To exit SQL*Plus command-line, enter EXIT.
To exit the Windows GUI, enter EXIT or select Exit from the File menu.
In iSQL*Plus, the EXIT or QUIT command halts the script currently running, it does not terminate your session.