Oracle PL/SQL - PL SQL Introduction Identifiers

Introduction

PL/SQL identifiers are names of PL/SQL program items.

The items could be constants, variables, exceptions, cursors, cursor variables, subprograms, and packages.

When creating identifiers, keep the following in mind:

  • An identifier cannot exceed 30 characters.
  • Every character, including dollar signs, underscores, and number signs, is significant. For example, v_index_nr and v__index_nr are different.
  • An identifier consists of a letter optionally followed by more letters, numerals, dollar signs, underscores, and number signs.

Example

Some examples of valid and invalid identifiers:

v_index_nr -- valid
v$index_nr -- valid
v index_nr -- invalid because of the space
5_index_nr -- invalid because it starts with a number
v-index_nr -- invalid because it contains -, a hyphen

By default, identifiers are not case sensitive, so v_index_nr and V_Index_NR are the same.

PL/SQL is case-insensitive for identifiers.

For example, the identifiers last_name, Last_Name, and LAST_NAME are the same.

A user-defined identifier has to follow the following rules:

  • Begins with a letter
  • Can include letters, digits, and these symbols: $ # _

A user-defined identifier cannot be a reserved word.

The following code lists examples of ordinary user-defined identifiers:

A 
t2 
T4
asdf# 
credit_card
FirstName
first$number 
asdf$$$tree 
SN## 
try_catch_ 

Examples of unacceptable user-defined identifiers:

mine&yours    -- cannot have &
debit-amount  -- cannot have -
on/off        -- cannot have /
user id       -- cannot have space

The identifier cannot exceed 30 bytes.

Related Topic