Database Programming with PL/SQL
2-2: Recognizing PL/SQL Lexical Units
Practice Activities
Vocabulary
An explicit numeric, character string, date, or Boolean value that is not represented by an identifier. - Literals
Symbols that have special meaning to an Oracle database. - Delimiters
Words that have special meaning to an Oracle database and cannot be used as identifiers. - Reserved words
Describe the purpose and use of each code segment and are ignored by PL/SQL. - Comments
Building blocks of any PL/SQL block and are sequences of characters including letters, digits, tabs, returns, and symbols. - Lexical Units
A name, up to 30 characters in length, given to a PL/SQL object. - Identifiers
Try it / Solve it
1. Identify each of the following identifiers as valid or invalid. If invalid, specify why.
Today Valid
Last name Invalid - contains a space
today’s_date Invalid - contains quote '
number_of_days_in_february_this_ year invalid contains more than 30 characters
Isleap$year valid
#number invalid - must start with a letter (not with #)
NUMBER# valid
Number1to7 valid
2. Identify the reserved words in the following list.
Reserved:
create
table
alter
rename
row
number
Not reserved:
make
seat
web
3. What kind of lexical unit (for example Reserved word, Delimiter, Literal, Comment) is each of the following?
SELECT Reserved word
:= Delimiter
'TEST' Literal
FALSE Literal
-- new process Comment
FROM Reserved word
/* select the country with the
highest elevation */ Comment
v_test Identificator
4.09 Literal
0 Comments