Show Menu
Cheatography

PL SQL Naming conventions Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

General rules

EVERYTHING
Give meaningful names
If not possible
Explain with comments
Page-width
120 characters per line
Case
lower case
Funcs & Procs
Everything should be in packages

Variables

Length
30 characters
Global Variable
g_<­var­iab­le_­nam­e>
Local Variable
l_<­var­iab­le_­nam­e>
Boolean Variable
b_<­var­iab­le_­nam­e>
Type
t_<­typ­e_n­ame>
Constant
c_<­con­sta­nt_­nam­e>
Cursor
cur_<c­urs­or_­nam­e>
Formal Input Parameter
i_<­par­ame­ter­_na­me>
Formal Output Parameter
o_<­par­ame­ter­_na­me>
Formal In / Out Parameter
io_<pa­ram­ete­r_n­ame>
For Loop Record
r_<­ent­ity>

Constr­aints

Primary key
Table : WORKIN­G_SETS
 
Primary Key : WORKIN­G_S­ETS_PK
Foreign keys
Relati­onship : DEVICES to DEVICE­_CL­ASSES
 
Foreign Key : DEVICE­S_D­EVI­CE_­CLA­SSES_FK
Unique keys
Table : WORKIN­G_SETS
 
Unique Key : WORKIN­G_S­ETS_UK
Check constr­aints
Table.C­olumn : DEVICE­S.F­EC_NAME
 
Check constraint : DEVICE­S_F­EC_­NAM­E_LC_CK
Not null constraint
Table.C­olumn : DEVICE­S.F­EC_NAME
 
Not null constraint : DEVICE­S_F­EC_­NAME_NN
 

Indexes

Primary keys Unique keys
Automa­tically have the same name as the constraint Let it
Single
Table.C­olumn : DEVICE­S.ALIAS
 
Index : DEVICE­S_A­LIAS_I
Multiple
Table.C­olumn : DEVICE­S.C­LASS, DEVICE­S.M­EMBER
 
Index : DEVICE­S_C­LAS­S_M­EMBER_I

Synonyms

Should not have any suffix to hide the implem­ent­ation

Triggers

To avoid when possible.
To avoid when possible. Can be necessary for technical operations (add dates/user to INSERT) or functional (less common)

Parameter Modes

Define the mode (in, out, in out)
Provide default when approp­riate

Sequences

Table : DEVICES
Sequence : DEVICE­S_SEQ

Views

Views
<na­me>_V
Materi­alized Views
<na­me>_MV

User Defined Types

Should be limited and used only where necessary.
table_­of_­tim­estamps
Only in one package
table_­of_­number
 
table_­of_­varchar