Reserved schema names and reserved words

There are restrictions on the use of certain names that are required by the database manager.

In some cases, names are reserved, and cannot be used by application programs. In other cases, certain names are not recommended for use by application programs, although their use is not prevented by the database manager.
The reserved schema names are:

It is strongly recommended that schema names never begin with the 'SYS' prefix, because 'SYS', by convention, is used to indicate an area that is reserved by the system. No aliases, global variables, triggers, user-defined functions, or user-defined types can be placed into a schema whose name starts with 'SYS' (SQLSTATE 42939).

The DB2QP schema and the SYSTOOLS schema are set aside for utilities used by the database. It is recommended that users not explicitly define objects in these schemas, although their use is not prevented by the database manager.

It is recommended that schema names never begin with the 'Q' prefix, because on other Db2® database managers 'Q', by convention, is used to indicate an area reserved by the system.

It is also recommended that SESSION not be used as a schema name. Because declared temporary tables must be qualified by SESSION, it is possible to have an application declare a temporary table with a name that is identical to that of a persistent table, complicating the application logic. To avoid this possibility, do not use the schema SESSION except when dealing with declared temporary tables.

Keywords can be used as ordinary identifiers, except in a context where they could also be interpreted as SQL keywords. In such cases, the word must be specified as a delimited identifier. For example, COUNT cannot be used as a column name in a SELECT statement, unless it is delimited.

ISO/ANSI SQL2003 and other IBM® database products include reserved words that are not enforced by Db2; however, it is recommended that these words not be used as ordinary identifiers, because it reduces portability.

For portability across the IBM database products, the following words should be considered reserved words:

ACTIVATE               DOUBLE               LOCALE               RESULT                           WLM
ADD                    DROP                 LOCALTIME            RESULT_SET_LOCATOR               WRITE
AFTER                  DSSIZE               LOCALTIMESTAMP       RETURN                           XMLELEMENT
ALIAS                  DYNAMIC              LOCATOR              RETURNS                          XMLEXISTS
ALL                    EACH                 LOCATORS             REVOKE                           XMLNAMESPACES
ALLOCATE               EDITPROC             LOCK                 RIGHT                            YEAR
ALLOW                  ELSE                 LOCKMAX              ROLE                             YEARS
ALTER                  ELSEIF               LOCKSIZE             ROLLBACK	
AND                    ENABLE               LONG                 ROUND_CEILING	
ANY                    ENCODING             LOOP                 ROUND_DOWN	
AS                     ENCRYPTION           MAINTAINED           ROUND_FLOOR	
ASENSITIVE             END                  MATERIALIZED         ROUND_HALF_DOWN	
ASSOCIATE              END-EXEC             MAXVALUE             ROUND_HALF_EVEN	
ASUTIME                ENDING               MICROSECOND          ROUND_HALF_UP	
AT                     ERASE                MICROSECONDS         ROUND_UP	
ATTRIBUTES             ESCAPE               MINUTE               ROUTINE	
AUDIT                  EVERY                MINUTES              ROW	
AUTHORIZATION          EXCEPT               MINVALUE             ROWNUMBER	
AUX                    EXCEPTION            MODE                 ROWS	
AUXILIARY              EXCLUDING            MODIFIES             ROWSET	
BEFORE                 EXCLUSIVE            MONTH                ROW_NUMBER	
BEGIN                  EXECUTE              MONTHS               RRN	
BETWEEN                EXISTS               NAN                  RUN	
BINARY                 EXIT                 NEW                  SAVEPOINT	
BUFFERPOOL             EXPLAIN              NEW_TABLE            SCHEMA	
BY                     EXTENDED             NEXTVAL              SCRATCHPAD	
CACHE                  EXTERNAL             NO                   SCROLL	
CALL                   EXTRACT              NOCACHE              SEARCH	
CALLED                 FENCED               NOCYCLE              SECOND	
CAPTURE                FETCH                NODENAME             SECONDS	
CARDINALITY            FIELDPROC            NODENUMBER           SECQTY	
CASCADED               FILE                 NOMAXVALUE           SECURITY	
CASE                   FINAL                NOMINVALUE           SELECT	
CAST                   FIRST1               NONE                 SENSITIVE	
CCSID                  FOR                  NOORDER              SEQUENCE	
CHAR                   FOREIGN              NORMALIZED           SESSION	
CHARACTER              FREE                 NOT2                 SESSION_USER	
CHECK                  FROM                 NOTNULL              SET	
CLONE                  FULL                 NULL                 SIGNAL	
CLOSE                  FUNCTION             NULLS                SIMPLE	
CLUSTER                GENERAL              NUMPARTS             SNAN	
COLLECTION             GENERATED            OBID                 SOME	
COLLID                 GET                  OF                   SOURCE	
COLUMN                 GLOBAL               OFF                  SPECIFIC	
COMMENT                GO                   OFFSET               SQL	
COMMIT                 GOTO                 OLD                  SQLID	
CONCAT                 GRANT                OLD_TABLE            STACKED	
CONDITION              GRAPHIC              ON                   STANDARD	
CONNECT                GROUP                OPEN                 START	
CONNECTION             HANDLER              OPTIMIZATION         STARTING	
CONSTRAINT             HASH                 OPTIMIZE             STATEMENT	
CONTAINS               HASHED_VALUE         OPTION               STATIC	
CONTINUE               HAVING               OR                   STATMENT	
COUNT                  HINT                 ORDER                STAY	
COUNT_BIG              HOLD                 OUT                  STOGROUP	
CREATE                 HOUR                 OUTER                STORES	
CROSS                  HOURS                OVER                 STYLE	
CURRENT                IDENTITY             OVERRIDING           SUBSTRING	
CURRENT_DATE           IF                   PACKAGE              SUMMARY	
CURRENT_LC_CTYPE       IMMEDIATE            PADDED               SYNONYM	
CURRENT_PATH           IMPORT               PAGESIZE             SYSFUN	
CURRENT_SCHEMA         IN                   PARAMETER            SYSIBM	
CURRENT_SERVER         INCLUDING            PART                 SYSPROC	
CURRENT_TIME           INCLUSIVE            PARTITION            SYSTEM	
CURSOR                 INDICATORS           PASSWORD             THEN	
CYCLE                  INF                  PATH                 TIME	
DATA                   INFINITY             PERCENT              TIMESTAMP	
DATABASE               INHERIT              PIECESIZE            TO	
DATAPARTITIONNAME      INNER                PLAN                 TRANSACTION	
DATAPARTITIONNUM       INOUT                POSITION             TRIGGER	
DATE                   INSENSITIVE          PRECISION            TRIM	
DAY                    INSERT               PREPARE              TRUNCATE	
DAYS                   INTEGRITY            PREVVAL              TYPE	
DB2GENERAL             INTERSECT            PRIMARY              UNDO	
DB2GENRL               INTO                 PRIQTY               UNION	
DB2SQL                 IS                   PRIVILEGES           UNIQUE	
DBINFO                 ISNULL               PROCEDURE            UNTIL	
DBPARTITIONNAME        ISOBID               PROGRAM              UPDATE	
DBPARTITIONNUM         ISOLATION            PSID                 USAGE	
DEALLOCATE             ITERATE              PUBLIC               USER	
DECLARE                JAR                  QUERY                USING	
DEFAULT                JAVA                 QUERYNO              VALIDPROC	
DEFAULTS               JOIN                 RANGE                VALUE	
DEFINITION             KEEP                 RANK                 VALUES	
DELETE                 KEY                  READ                 VARIABLE	
DENSERANK              LABEL                READS                VARIANT	
DENSE_RANK             LANGUAGE             RECOVERY             VCAT	
DESCRIBE               LAST3                REFERENCES           VERSION	
DESCRIPTOR             LATERAL              REFERENCING          VIEW	
DETERMINISTIC          LC_CTYPE             REFRESH              VOLATILE	
DIAGNOSTICS            LEAVE                RELEASE              VOLUMES	
DISABLE                LEFT                 RENAME               WHEN	
DISALLOW               LIKE                 REPEAT               WHENEVER	
DISCONNECT             LIMIT                RESET                WHERE	
DISTINCT               LINKTYPE             RESIGNAL             WHILE	
DO                     LOCAL                RESTART              WITH	
DOCUMENT               LOCALDATE            RESTRICT             WITHOUT	
ISO/ANSI SQL2003 reserved words that are not in the previous list:

ABS                               GROUPING         REGR_INTERCEPT
ARE                               INT              REGR_R2
ARRAY                             INTEGER          REGR_SLOPE
ASYMMETRIC                        INTERSECTION     REGR_SXX
ATOMIC                            INTERVAL         REGR_SXY
AVG                               LARGE            REGR_SYY
BIGINT                            LEADING          ROLLUP
BLOB                              LN               SCOPE
BOOLEAN                           LOWER            SIMILAR
BOTH                              MATCH            SMALLINT
CEIL                              MAX              SPECIFICTYPE
CEILING                           MEMBER           SQLEXCEPTION
CHAR_LENGTH                       MERGE            SQLSTATE
CLOB                              MIN              SQRT
COALESCE                          MOD              STDDEV_POP
COLLATE                           MODULE           STDDEV_SAMP
COLLECT                           MULTISET         SUBMULTISET
CONVERT                           NATIONAL         SUM
CORR                              NATURAL          SYMMETRIC
CORRESPONDING                     NCHAR            TABLESAMPLE
COVAR_POP                         NCLOB            TIMEZONE_HOUR
COVAR_SAMP                        NORMALIZE        TIMEZONE_MINUTE
CUBE                              NULLIF           TRAILING
CUME_DIST                         NUMERIC          TRANSLATE
CURRENT_ROLE                      ONLY             TREAT
DEC                               OVERLAY          UESCAPE
DECIMAL                           PERCENT_RANK     UNKNOWN
DEREF                             PERCENTILE_CONT  UNNEST
ELEMENT                           PERCENTILE_DISC  UPPER
EXEC                              POWER            VAR_POP
EXP                               REAL             VAR_SAMP
FALSE                             RECURSIVE        VARBINARY
FILTER                            REF              VARCHAR
FLOAT                             REGR_AVGX        VARYING
FLOOR                             REGR_AVGY        WIDTH_BUCKET
FUSION                            REGR_COUNT       WINDOW
1 As of Db2 Version, FIRST is a SQL keyword in some expression contexts, for example, within an OLAP specification. This means FIRST, when used as an identifier, must be delimited when used within these contexts.
2 As of Db2 Version, NOT is a valid operator in certain contexts, for example, within a select-list. This means NOT, when used as an identifier, must be delimited when used within these contexts.
3 As of Db2 Version, LAST is a SQL keywords in some expression contexts, for example, within an OLAP specification. This means LAST, when used as an identifier, must be delimited when used within these contexts.