 |
|
The SELECT Statement
Oracle Tips by
Burleson
|
The SELECT statement is used to retrieve data from a table.
The basic format of a SELECT statement is as follows:
SELECT <column listing>
FROM <source table> <source table alias>
WHERE <one or more data conditions>;
If you wish to select all the columns that match your WHERE
clause, you may use an asterisk instead of naming all the columns from
your source table. The use of the WHERE clause is optional, but
excluding the clause will cause all the rows of data to be retrieved
from the table.
The use of a table alias is optional, but it is quite common in
queries that join two or more tables to return data. The basic format
when using a table alias is as follows:
SELECT <column listing>
FROM <source table> <source table alias>,
<source table> <source table alias>
WHERE <one or more data conditions>;
A table alias is most often used to abbreviate a table’s name so
that columns in the WHERE clause may be referenced with the
abbreviation instead of the table name. When two columns in different
tables share the same name, the desired column must be identified
using either a table name or table alias.
The use of an optional ORDER BY clause is quite common, as
well. The basic format of an ORDER BY clause is as follows:
SELECT <column listing>
FROM <table> <table alias>
WHERE <one or more data conditions>
ORDER BY <column>;
The ORDER BY clause instructs Oracle to gather the data and
then sort it according to one or more conditions. Use of this clause
adds overhead to the performance of the statement.
The UPDATE Statement
The UPDATE statement is used to modify data that already
exists in a table. The basic format of an UPDATE statement is
as follows:
UPDATE <table>
SET <column> = <value>,
<column> = <value>
WHERE <one or more data conditions>;
You may specify as many columns as you like in the SET
clause. The use of the WHERE clause is (once again) optional,
but excluding the clause will cause every row in the table to be
updated.
This is an excerpt from the book "High Performance Oracle
Database Automation" by Jonathan Ingram and Donald K.
Burleson, Series Editor. |