保留关键字 (Transact-SQL)
更新日期: 2006 年 7 月 17 日
Microsoft SQL Server 2005 使用保留关键字来定义、操作或访问数据库。 保留关键字是 SQL Server 使用的 Transact-SQL 语言语法的一部分,用于分析和理解 Transact-SQL 语句和批处理。 尽管在 Transact-SQL 脚本中使用 SQL Server 保留关键字作为标识符和对象名在语法上是可行的,但规定只能使用分隔标识符。
下表列出了 SQL Server 保留关键字。
ADD |
EXISTS |
PRIMARY |
ALL |
EXIT |
|
ALTER |
EXTERNAL |
PROC |
AND |
FETCH |
PROCEDURE |
ANY |
FILE |
PUBLIC |
AS |
FILLFACTOR |
RAISERROR |
ASC |
FOR |
READ |
AUTHORIZATION |
FOREIGN |
READTEXT |
BACKUP |
FREETEXT |
RECONFIGURE |
BEGIN |
FREETEXTTABLE |
REFERENCES |
BETWEEN |
FROM |
REPLICATION |
BREAK |
FULL |
RESTORE |
BROWSE |
FUNCTION |
RESTRICT |
BULK |
GOTO |
RETURN |
BY |
GRANT |
REVERT |
CASCADE |
GROUP |
REVOKE |
CASE |
HAVING |
RIGHT |
CHECK |
HOLDLOCK |
ROLLBACK |
CHECKPOINT |
IDENTITY |
ROWCOUNT |
CLOSE |
IDENTITY_INSERT |
ROWGUIDCOL |
CLUSTERED |
IDENTITYCOL |
RULE |
COALESCE |
IF |
SAVE |
COLLATE |
IN |
SCHEMA |
COLUMN |
INDEX |
SECURITYAUDIT |
COMMIT |
INNER |
SELECT |
COMPUTE |
INSERT |
SESSION_USER |
CONSTRAINT |
INTERSECT |
SET |
CONTAINS |
INTO |
SETUSER |
CONTAINSTABLE |
IS |
SHUTDOWN |
CONTINUE |
JOIN |
SOME |
CONVERT |
KEY |
STATISTICS |
CREATE |
KILL |
SYSTEM_USER |
CROSS |
LEFT |
TABLE |
CURRENT |
LIKE |
TABLESAMPLE |
CURRENT_DATE |
LINENO |
TEXTSIZE |
CURRENT_TIME |
LOAD |
THEN |
CURRENT_TIMESTAMP |
NATIONAL |
TO |
CURRENT_USER |
NOCHECK |
TOP |
CURSOR |
NONCLUSTERED |
TRAN |
DATABASE |
NOT |
TRANSACTION |
DBCC |
NULL |
TRIGGER |
DEALLOCATE |
NULLIF |
TRUNCATE |
DECLARE |
OF |
TSEQUAL |
DEFAULT |
OFF |
UNION |
DELETE |
OFFSETS |
UNIQUE |
DENY |
ON |
UNPIVOT |
DESC |
OPEN |
UPDATE |
DISK |
OPENDATASOURCE |
UPDATETEXT |
DISTINCT |
OPENQUERY |
USE |
DISTRIBUTED |
OPENROWSET |
USER |
DOUBLE |
OPENXML |
VALUES |
DROP |
OPTION |
VARYING |
DUMP |
OR |
VIEW |
ELSE |
ORDER |
WAITFOR |
END |
OUTER |
WHEN |
ERRLVL |
OVER |
WHERE |
ESCAPE |
PERCENT |
WHILE |
EXCEPT |
PIVOT |
WITH |
EXEC |
PLAN |
WRITETEXT |
EXECUTE |
PRECISION |
另外,SQL-2003 标准还定义了保留关键字列表。 不要使用 SQL-2003 保留关键字作为对象名和标识符。 ODBC 保留关键字列表(如下表所示)与 SQL-2003 保留关键字列表相同。
注意: |
---|
SQL-2003 保留关键字列表有时可能比 SQL Server 限制更多,有时则限制更少。 例如,SQL-2003 保留关键字列表包含 INT,而 SQL Server 不需要将其区分为保留关键字。 |
Transact-SQL 保留关键字可用作数据库或数据库对象(如表、列、视图等)的标识符或名称。 使用带引号的标识符或分隔标识符。 不限制将保留关键字用作变量和存储过程参数的名称。 有关详细信息,请参阅使用标识符作为对象名称。
ODBC 保留关键字
保留了下列关键字以用于 ODBC 函数调用。 这些关键字根本不约束 SQL 语法;然而,为确保与支持核心 SQL 语法的驱动程序兼容,应用程序应避免使用这些关键字。
下面是当前的 ODBC 保留关键字列表。
ABSOLUTE |
EXEC |
OVERLAPS |
ACTION |
EXECUTE |
PAD |
ADA |
EXISTS |
PARTIAL |
ADD |
EXTERNAL |
PASCAL |
ALL |
EXTRACT |
POSITION |
ALLOCATE |
FALSE |
PRECISION |
ALTER |
FETCH |
PREPARE |
AND |
FIRST |
PRESERVE |
ANY |
FLOAT |
PRIMARY |
ARE |
FOR |
PRIOR |
AS |
FOREIGN |
PRIVILEGES |
ASC |
FORTRAN |
PROCEDURE |
ASSERTION |
FOUND |
PUBLIC |
AT |
FROM |
READ |
AUTHORIZATION |
FULL |
REAL |
AVG |
GET |
REFERENCES |
BEGIN |
GLOBAL |
RELATIVE |
BETWEEN |
GO |
RESTRICT |
BIT |
GOTO |
REVOKE |
BIT_LENGTH |
GRANT |
RIGHT |
BOTH |
GROUP |
ROLLBACK |
BY |
HAVING |
ROWS |
CASCADE |
HOUR |
SCHEMA |
CASCADED |
IDENTITY |
SCROLL |
CASE |
IMMEDIATE |
SECOND |
CAST |
IN |
SECTION |
CATALOG |
INCLUDE |
SELECT |
CHAR |
INDEX |
SESSION |
CHAR_LENGTH |
INDICATOR |
SESSION_USER |
CHARACTER |
INITIALLY |
SET |
CHARACTER_LENGTH |
INNER |
SIZE |
CHECK |
INPUT |
SMALLINT |
CLOSE |
INSENSITIVE |
SOME |
COALESCE |
INSERT |
SPACE |
COLLATE |
INT |
SQL |
COLLATION |
INTEGER |
SQLCA |
COLUMN |
INTERSECT |
SQLCODE |
COMMIT |
INTERVAL |
SQLERROR |
CONNECT |
INTO |
SQLSTATE |
CONNECTION |
IS |
SQLWARNING |
CONSTRAINT |
ISOLATION |
SUBSTRING |
CONSTRAINTS |
JOIN |
SUM |
CONTINUE |
KEY |
SYSTEM_USER |
CONVERT |
LANGUAGE |
TABLE |
CORRESPONDING |
LAST |
TEMPORARY |
COUNT |
LEADING |
THEN |
CREATE |
LEFT |
TIME |
CROSS |
LEVEL |
TIMESTAMP |
CURRENT |
LIKE |
TIMEZONE_HOUR |
CURRENT_DATE |
LOCAL |
TIMEZONE_MINUTE |
CURRENT_TIME |
LOWER |
TO |
CURRENT_TIMESTAMP |
MATCH |
TRAILING |
CURRENT_USER |
MAX |
TRANSACTION |
CURSOR |
MIN |
TRANSLATE |
DATE |
MINUTE |
TRANSLATION |
DAY |
MODULE |
TRIM |
DEALLOCATE |
MONTH |
TRUE |
DEC |
NAMES |
UNION |
DECIMAL |
NATIONAL |
UNIQUE |
DECLARE |
NATURAL |
UNKNOWN |
DEFAULT |
NCHAR |
UPDATE |
DEFERRABLE |
NEXT |
UPPER |
DEFERRED |
NO |
USAGE |
DELETE |
NONE |
USER |
DESC |
NOT |
USING |
DESCRIBE |
NULL |
VALUE |
DESCRIPTOR |
NULLIF |
VALUES |
DIAGNOSTICS |
NUMERIC |
VARCHAR |
DISCONNECT |
OCTET_LENGTH |
VARYING |
DISTINCT |
OF |
VIEW |
DOMAIN |
ON |
WHEN |
DOUBLE |
ONLY |
WHENEVER |
DROP |
OPEN |
WHERE |
ELSE |
OPTION |
WITH |
END |
OR |
WORK |
END-EXEC |
ORDER |
WRITE |
ESCAPE |
OUTER |
YEAR |
EXCEPT |
OUTPUT |
ZONE |
EXCEPTION |
|
|
将来的关键字
下列关键字可能会在将来的 SQL Server 版本中保留使用,作为将来要实现的新功能。 注意,不要使用这些关键字作为标识符。
ABSOLUTE |
FREE |
PRESERVE |
ACTION |
FULLTEXTTABLE |
PRIOR |
ADMIN |
GENERAL |
PRIVILEGES |
AFTER |
GET |
READS |
AGGREGATE |
GLOBAL |
REAL |
ALIAS |
GO |
RECURSIVE |
ALLOCATE |
GROUPING |
REF |
ARE |
HOST |
REFERENCING |
ARRAY |
HOUR |
RELATIVE |
ASSERTION |
IGNORE |
RESULT |
AT |
IMMEDIATE |
RETURNS |
BEFORE |
INDICATOR |
ROLE |
BINARY |
INITIALIZE |
ROLLUP |
BIT |
INITIALLY |
ROUTINE |
BLOB |
INOUT |
ROW |
BOOLEAN |
INPUT |
ROWS |
BOTH |
INT |
SAVEPOINT |
BREADTH |
INTEGER |
SCROLL |
CALL |
INTERVAL |
SCOPE |
CASCADED |
ISOLATION |
SEARCH |
CAST |
ITERATE |
SECOND |
CATALOG |
LANGUAGE |
SECTION |
CHAR |
LARGE |
SEQUENCE |
CHARACTER |
LAST |
SESSION |
CLASS |
LATERAL |
SETS |
CLOB |
LEADING |
SIZE |
COLLATION |
LESS |
SMALLINT |
COMPLETION |
LEVEL |
SPACE |
CONNECT |
LIMIT |
SPECIFIC |
CONNECTION |
LOCAL |
SPECIFICTYPE |
CONSTRAINTS |
LOCALTIME |
SQL |
CONSTRUCTOR |
LOCALTIMESTAMP |
SQLEXCEPTION |
CORRESPONDING |
LOCATOR |
SQLSTATE |
CUBE |
MAP |
SQLWARNING |
CURRENT_PATH |
MATCH |
START |
CURRENT_ROLE |
MINUTE |
STATE |
CYCLE |
MODIFIES |
STATEMENT |
DATA |
MODIFY |
STATIC |
DATE |
MODULE |
STRUCTURE |
DAY |
MONTH |
TEMPORARY |
DEC |
NAMES |
TERMINATE |
DECIMAL |
NATURAL |
THAN |
DEFERRABLE |
NCHAR |
TIME |
DEFERRED |
NCLOB |
TIMESTAMP |
DEPTH |
NEW |
TIMEZONE_HOUR |
DEREF |
NEXT |
TIMEZONE_MINUTE |
DESCRIBE |
NO |
TRAILING |
DESCRIPTOR |
NONE |
TRANSLATION |
DESTROY |
NUMERIC |
TREAT |
DESTRUCTOR |
OBJECT |
TRUE |
DETERMINISTIC |
OLD |
UNDER |
DICTIONARY |
ONLY |
UNKNOWN |
DIAGNOSTICS |
OPERATION |
UNNEST |
DISCONNECT |
ORDINALITY |
USAGE |
DOMAIN |
OUT |
USING |
DYNAMIC |
OUTPUT |
VALUE |
EACH |
PAD |
VARCHAR |
END-EXEC |
PARAMETER |
VARIABLE |
EQUALS |
PARAMETERS |
WHENEVER |
EVERY |
PARTIAL |
WITHOUT |
EXCEPTION |
PATH |
WORK |
FALSE |
POSTFIX |
WRITE |
FIRST |
PREFIX |
YEAR |
FLOAT |
PREORDER |
ZONE |
FOUND |
PREPARE |
请参阅
参考
SET QUOTED_IDENTIFIER (Transact-SQL)
其他资源
帮助和信息
更改历史记录
发布日期 | 历史记录 |
---|---|
2006 年 7 月 17 日 |
|