Running SQL Queries
Using SQL*Plus , you can execute any SQL query or statement that you desire. This includes data manipulation language (DML) statements such as INSERT, UPDATE, DELETE, MERGE, and SELECT. This also includes data definition language (DDL) statements such as CREATE TABLE, CREATE INDEX, CREATE USER, and so on. Essentially, you can execute any statement listed in the Oracle SQL Reference manual.
Example 2-1 shows a
simple SELECT statement against the project
table.
Example 2-1. A simple SELECT statement
SQL>SELECT * /* All columns */
2FROM project;
PROJECT_ID PROJECT_NAME PROJECT_BUDGET ---------- ---------------------------------------- -------------- 1001 Corporate Web Site 1912000 1002 Enterprise Resource Planning System 9999999 1003 Accounting System Implementation 897000 1004 Data Warehouse Maintenance 294000 1005 VPN Implementation 415000
Look again at the query shown in the example. Notice that the statement spans more than one line. Notice that it contains an embedded comment and that it ends with a semicolon. All of these things are important because they illustrate the following rules for entering SQL statements:
SQL statements may span multiple lines.
Line breaks may occur anywhere SQL allows whitespace, but blank lines are not normally allowed.
Comments, delimited by /*...*/, may be embedded anywhere whitespace is allowed. A comment entered this way may span multiple lines.
Comments denoted by a leading dash (
-
) may be added anywhere in a line and mark the ...
Get Oracle SQL*Plus: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.