How to use SQL*Plus in Oracle

In this section, learn how to use SQL*Plus in Oracle, which may be used to run SQL statement and scripts if an Oracle database does not have SQL Developer installed.

Murach's Oracle SQL and PL/SQL

PL/SQL Book
 

Chapter 2, How to use Oracle SQL Developer and other tools

This chapter from Murach's Oracle SQL and PL/SQL explains how to work with Oracle SQL Developer and other tools. In this section, learn how to use SQL*Plus in Oracle, which may be used to run SQL statements and scripts if an Oracle database does not have an SQL Developer installation. 

 

 

 

 

Table of contents:

How to work with an Oracle database home page
How to use SQL Plus in Oracle 
How to use SQL Developer to work with an Oracle database
How to view and edit table column definitions
How to use SQL Developer to run SQL statements 
How to use the Oracle Database SQL Reference manual 
 

 

Figure 2-3 shows how to use a command-line tool known as SQL*Plus to work with the database. The SQL*Plus tool has been around since the earliest days of the Oracle database, and many Oracle developers still use it. However, the newer SQL Developer tool described later in this chapter is easier to learn and use than the SQL*Plus tool. That's why this chapter and the rest of this book shows how to work with the SQL Developer tool.

For more on this book
This chapter is excerpted from the book, Murach's Oracle SQL and PL/SQL, authored by Joel Murach, published by Mike Murach & Associates, Inc., August, 2008. ISBN: 978-1-890774-50-9.

Still, there may be times when it makes sense to use SQL*Plus. If, for example, you are working on a computer that has SQL*Plus installed but doesn't have SQL Developer installed, you may need to use SQL*Plus to run some SQL statements. Or, you may need to develop a batch file that uses SQL*Plus to run one or more SQL scripts. Figure A-5 of appendix A, for example, shows how to run a batch file that starts SQL*Plus and uses it to run four SQL scripts. In that case, of course, it makes sense to use SQL*Plus..

If you need to start SQL*Plus, you can do that by selecting the Run command from the Start menu, entering "sqlplus", and selecting the OK button. Then, you can connect to the database as a user by entering the username and password. In this figure, for example, I started by connecting as the AP user..

Once you're connected to the database, you can run SQL statements. To do that, you type the SQL statement followed by a semicolon and press the Enter key. Then, if the statement selects data, SQL*Plus will display the data. In this figure, for example, I entered a SQL statement that displays the vendor_name for the vendor with an id of 11..

At any time, you can connect to the database as a different user by entering the CONNECT command. When you enter this command, SQL*Plus prompts you for a username and password. In this figure, for example, I entered the CONNECT command to connect as the OM user.

More on Oracle and SQL

Check out the expert response on creating a virtual SQL table for date values

Learn how to make Monday the start of the week in Oracle SQL

Read about usingSQL SELECT and SQL UNION ALL statements to sort numbers

The SQL*Plus tool

The SQL*Plus tool 

Figure 2-3 How to use SQL*Plus

Description

  • SQL*Plus is a command-line tool that's installed with the Oracle Database. You can use it to work with an Oracle Database.
  • To start SQL*Plus, select the Run command from the Start menu, enter "sqlplus", and select the OK button.
  • To connect to a database, enter the username and password. If necessary, you can enter the CONNECT command to have SQL*Plus prompt you for a username and password.
  • To run a SQL statement, type it, type a semicolon, and press the Enter key.
  • For most tasks, it's easier to use the SQL Developer tool that's described later in this chapter.

Download the chapter "How to use Oracle SQL Developer and other tools" in PDF form. 

Continue to the next section: How to use SQL Developer to work with an Oracle database

Dig Deeper on Oracle database administration