Oracle9i SQL Reference
Release 1 (9.0.1)

Part Number A90125-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

Basic Elements of Oracle SQL, 9 of 10


Schema Object Names and Qualifiers

This section provides:

Schema Object Naming Rules

The following rules apply when naming schema objects:

  1. Names must be from 1 to 30 bytes long with these exceptions:

    • Names of databases are limited to 8 bytes.

    • Names of database links can be as long as 128 bytes.

  2. Names cannot contain quotation marks.

  3. Names are not case sensitive.

  4. A name must begin with an alphabetic character from your database character set unless surrounded by double quotation marks.

  5. Names can contain only alphanumeric characters from your database character set and the underscore (_), dollar sign ($), and pound sign (#). Oracle strongly discourages you from using $ and #. Names of database links can also contain periods (.) and "at" signs (@).

    If your database character set contains multibyte characters, Oracle recommends that each name for a user or a role contain at least one single-byte character.


    Note:

    You cannot use special characters from European or Asian character sets in a database name, global database name, or database link names. For example, characters with an umlaut are not allowed. 


  6. A name cannot be an Oracle reserved word.

    Depending on the Oracle product you plan to use to access a database object, names might be further restricted by other product-specific reserved words.

    See Also:

     
  7. Do not use the word DUAL as a name for an object or part. DUAL is the name of a dummy table.

    See Also:

    "Selecting from the DUAL Table" 

  8. The Oracle SQL language contains other words that have special meanings. These words include datatypes, function names, and keywords (the uppercase words in SQL statements, such as DIMENSION, SEGMENT, ALLOCATE, DISABLE, and so forth). These words are not reserved. However, Oracle uses them internally. Therefore, if you use these words as names for objects and object parts, your SQL statements may be more difficult to read and may lead to unpredictable results.

    In particular, do not use words beginning with "SYS_" as schema object names, and do not use the names of SQL built-in functions for the names of schema objects or user-defined functions.

    See Also:

    "Datatypes" and "SQL Functions" 

  9. Within a namespace, no two objects can have the same name.

    The following schema objects share one namespace:

    • Tables

    • Views

    • Sequences

    • Private synonyms

    • Stand-alone procedures

    • Stand-alone stored functions

    • Packages

    • Materialized views

    • User-defined types

    Each of the following schema objects has its own namespace:

    • Indexes

    • Constraints

    • Clusters

    • Database triggers

    • Private database links

    • Dimensions

    Because tables and views are in the same namespace, a table and a view in the same schema cannot have the same name. However, tables and indexes are in different namespaces. Therefore, a table and an index in the same schema can have the same name.

    Each schema in the database has its own namespaces for the objects it contains. This means, for example, that two tables in different schemas are in different namespaces and can have the same name.

    Each of the following nonschema objects also has its own namespace:

    • User roles

    • Public synonyms

    • Public database links

    • Tablespaces

    • Rollback segments

    • Profiles

    • Parameter files (PFILEs) and server parameter files (SPFILEs)

    Because the objects in these namespaces are not contained in schemas, these namespaces span the entire database.

  10. Columns in the same table or view cannot have the same name. However, columns in different tables or views can have the same name.

  11. Procedures or functions contained in the same package can have the same name, if their arguments are not of the same number and datatypes. Creating multiple procedures or functions with the same name in the same package with different arguments is called overloading the procedure or function.

  12. A name can be enclosed in double quotation marks. Such names can contain any combination of characters, including spaces, ignoring rules 3 through 7 in this list. This exception is allowed for portability, but Oracle recommends that you do not break rules 3 through 7.

    If you give a schema object a name enclosed in double quotation marks, you must use double quotation marks whenever you refer to the object.

    Enclosing a name in double quotes enables it to:

    • Contain spaces

    • Be case sensitive

    • Begin with a character other than an alphabetic character, such as a numeric character

    • Contain characters other than alphanumeric characters and _, $, and #

    • Be a reserved word

    By enclosing names in double quotation marks, you can give the following names to different objects in the same namespace:

    emp
    "emp"
    "Emp"
    "EMP "
    
    

    Note that Oracle interprets the following names the same, so they cannot be used for different objects in the same namespace:

    emp
    EMP
    "EMP"
    
    

    If you give a user or password a quoted name, the name cannot contain lowercase letters.

    Database link names cannot be quoted.

Schema Object Naming Examples

The following examples are valid schema object names:

ename
horse
scott.hiredate
"EVEN THIS & THAT!"
a_very_long_and_valid_name

Although column aliases, table aliases, usernames, and passwords are not objects or parts of objects, they must also follow these naming rules with these exceptions:

Schema Object Naming Guidelines

Here are several helpful guidelines for naming objects and their parts:

When naming objects, balance the objective of keeping names short and easy to use with the objective of making names as descriptive as possible. When in doubt, choose the more descriptive name, because the objects in the database may be used by many people over a period of time. Your counterpart ten years from now may have difficulty understanding a database with a name like pmdd instead of payment_due_date.

Using consistent naming rules helps users understand the part that each table plays in your application. One such rule might be to begin the names of all tables belonging to the FINANCE application with fin_.

Use the same names to describe the same things across tables. For example, the department number columns of the sample employees and departments tables are both named deptno.


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback