General naming rules

Rules exist for the naming of all database objects, user names, passwords, groups, files, and paths. Some of these rules are specific to the platform you are working on.

For example, regarding the use of upper and lowercase letters in the names of objects that are visible in the file system (databases, instances, and so on):

  • On UNIX platforms, names are case-sensitive. For example, /data1 is not the same directory as /DATA1 or /Data1
  • On Windows platforms, names are not case-sensitive. For example, \data1 is the same as \DATA1 and \Data1.

Unless otherwise specified, all names can include the following characters:

  • The letters A through Z, and a through z, as defined in the basic (7-bit) ASCII character set. When used in identifiers for objects created with SQL statements, lowercase characters "a" through "z" are converted to uppercase unless they are delimited with quotation marks (")
  • 0 through 9.
  • ! % ( ) { } . - ^ ~ _ (underscore) @, #, $, and space.
  • \ (backslash).


Restrictions

  • Do not begin names with a number or with the underscore character.
  • Do not use SQL reserved words to name tables, views, columns, indexes, or authorization IDs.
  • Use only the letters defined in the basic ASCII character set for directory and file names. While your computer's operating system might support different code pages, non-ASCII characters might not work reliably. Using non-ASCII characters can be a particular problem in distributed environment, where different computers might be using different code pages.
  • There are other special characters that might work separately depending on your operating system and where you are working with the Db2® database. However, while they might work, there is no guarantee that they will work. It is not recommended that you use these other special characters when naming objects in your database.
  • Lengths must be less than or equal to the lengths listed in: SQL and XML limits.
  • Restrictions on the authorization ID: When the authorization ID is interpreted as an operating system user ID or group name, Db2 imposed naming restrictions apply. For details, see the User, user ID and group naming rules page.

You also must consider object naming rules, naming rules in an multicultural support environment, and naming rules in a Unicode environment.