Datasheet
Summary
51
DEPARTMENT_NAME DEPARTMENT_ID
------------------------------ -------------
Administration 10
1 row selected.
SQL>
If you save the SQL as a script file, you can submit the substitution-variable values while
invoking the script (as command-line arguments). Each time you run this command file,
START
replaces each
&1 in the file with the first value (called an argument) after START file n a m e ,
then replaces each
&2 with the second value, and so forth. Here is an example of saving
and running the previous query:
SQL> SAVE ex02
Created file ex02.sql
SQL> SET VERIFY OFF
SQL> @ex02 department_id 20
DEPARTMENT_NAME DEPARTMENT_ID
------------------------------ -------------
Marketing 20
1 row selected.
SQL>
Although I did not specify two ampersands for positional substitution variables, SQL*Plus
keeps the values of these variables for the session (since we passed the values as parameters
to a script file). Next time you run any script with positional substitution variables, Oracle
uses these values to execute the script.
Summary
This chapter started off with reviewing the fundamentals of SQL. You also saw an overview
of SQL*Plus in this chapter. SQL*Plus is Oracle’s native tool to interact with the database.
You got a quick introduction to the Oracle datatypes, operators, and literals. You learned
to write simple queries using the
SELECT statement. You also learned to use the WHERE clause
and the
ORDER BY clause in this chapter.
The CHAR and VARCHAR2 datatypes are used to store alphanumeric information.
The NUMBER datatype is used to store any numeric value. Date values can be stored using
the DATE or TIMESTAMP datatypes. Oracle has a wide range of operators: arithmetic,
concatenation, comparison, membership, logical, pattern matching, range, existence, and
NULL checking. The CASE expression is used to bring conditional logic to SQL.
95127c01.indd 51 2/18/09 6:37:11 AM