SQL Server 的保留关键字一览

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 14:01:42

SQL Server 保留关键字

Microsoft® SQL Server™ 2000 使用保留关键字定义、操作和访问数据库。保留关键字是 SQL Server 使用的 Transact-SQL 语言语法的一部分,用于分析和理解 Transact-SQL 语句和批处理。尽管在 Transact-SQL 脚本中,使用 SQL Server 保留关键字作为标识符和对象名在语法上是可行的,但规定只能使用分隔标识符。

下表列出了 SQL Server 的保留关键字。

ADDEXCEPTPERCENT
ALLEXECPLAN
ALTEREXECUTEPRECISION
ANDEXISTSPRIMARY
ANYEXITPRINT
ASFETCHPROC
ASCFILEPROCEDURE
AUTHORIZATIONFILLFACTORPUBLIC
BACKUPFORRAISERROR
BEGINFOREIGNREAD
BETWEENFREETEXTREADTEXT
BREAKFREETEXTTABLERECONFIGURE
BROWSEFROMREFERENCES
BULKFULLREPLICATION
BYFUNCTIONRESTORE
CASCADEGOTORESTRICT
CASEGRANTRETURN
CHECKGROUPREVOKE
CHECKPOINTHAVINGRIGHT
CLOSEHOLDLOCKROLLBACK
CLUSTEREDIDENTITYROWCOUNT
COALESCEIDENTITY_INSERTROWGUIDCOL
COLLATEIDENTITYCOLRULE
COLUMNIFSAVE
COMMITINSCHEMA
COMPUTEINDEXSELECT
CONSTRAINTINNERSESSION_USER
CONTAINSINSERTSET
CONTAINSTABLEINTERSECTSETUSER
CONTINUEINTOSHUTDOWN
CONVERTISSOME
CREATEJOINSTATISTICS
CROSSKEYSYSTEM_USER
CURRENTKILLTABLE
CURRENT_DATELEFTTEXTSIZE
CURRENT_TIMELIKETHEN
CURRENT_TIMESTAMPLINENOTO
CURRENT_USERLOADTOP
CURSORNATIONALTRAN
DATABASENOCHECKTRANSACTION
DBCCNONCLUSTEREDTRIGGER
DEALLOCATENOTTRUNCATE
DECLARENULLTSEQUAL
DEFAULTNULLIFUNION
DELETEOFUNIQUE
DENYOFFUPDATE
DESCOFFSETSUPDATETEXT
DISKONUSE
DISTINCTOPENUSER
DISTRIBUTEDOPENDATASOURCEVALUES
DOUBLEOPENQUERYVARYING
DROPOPENROWSETVIEW
DUMMYOPENXMLWAITFOR
DUMPOPTIONWHEN
ELSEORWHERE
ENDORDERWHILE
ERRLVLOUTERWITH
ESCAPEOVERWRITETEXT

另外,SQL-92 标准还定义了保留关键字列表。不要使用 SQL-92 保留关键字作为对象名和标识符。ODBC 保留关键字列表(如下所示)与 SQL-92 保留关键字列表相同。

说明  SQL-92 保留关键字列表有时可能比 SQL Server 限制更多,有时则限制更少。例如,SQL-92 保留关键字列表包含 INT,而 SQL Server 不需要将其区分为保留关键字。

Transact-SQL 保留关键字可用作数据库或数据库对象(如表、列、视图等)的标识符或名称。使用被引用的标识符或分隔标识符。对将保留关键字用作变量和存储过程参数的名称没有限制。

ODBC 保留关键字

保留了下列关键字用于 ODBC 函数调用。这些关键字根本不约束 SQL 语法;然而,为确保与支持核心 SQL 语法的驱动程序兼容,应用程序应避免使用这些关键字。

下面是当前的 ODBC 保留关键字列表。有关更多信息,请参见《Microsoft ODBC 3.0 程序员参考》,第 2 卷,附录 C。

ABSOLUTEEXECOVERLAPS
ACTIONEXECUTEPAD
ADAEXISTSPARTIAL
ADDEXTERNALPASCAL
ALLEXTRACTPOSITION
ALLOCATEFALSEPRECISION
ALTERFETCHPREPARE
ANDFIRSTPRESERVE
ANYFLOATPRIMARY
AREFORPRIOR
ASFOREIGNPRIVILEGES
ASCFORTRANPROCEDURE
ASSERTIONFOUNDPUBLIC
ATFROMREAD
AUTHORIZATIONFULLREAL
AVGGETREFERENCES
BEGINGLOBALRELATIVE
BETWEENGORESTRICT
BITGOTOREVOKE
BIT_LENGTHGRANTRIGHT
BOTHGROUPROLLBACK
BYHAVINGROWS
CASCADEHOURSCHEMA
CASCADEDIDENTITYSCROLL
CASEIMMEDIATESECOND
CASTINSECTION
CATALOGINCLUDESELECT
CHARINDEXSESSION
CHAR_LENGTHINDICATORSESSION_USER
CHARACTERINITIALLYSET
CHARACTER_LENGTHINNERSIZE
CHECKINPUTSMALLINT
CLOSEINSENSITIVESOME
COALESCEINSERTSPACE
COLLATEINTSQL
COLLATIONINTEGERSQLCA
COLUMNINTERSECTSQLCODE
COMMITINTERVALSQLERROR
CONNECTINTOSQLSTATE
CONNECTIONISSQLWARNING
CONSTRAINTISOLATIONSUBSTRING
CONSTRAINTSJOINSUM
CONTINUEKEYSYSTEM_USER
CONVERTLANGUAGETABLE
CORRESPONDINGLASTTEMPORARY
COUNTLEADINGTHEN
CREATELEFTTIME
CROSSLEVELTIMESTAMP
CURRENTLIKETIMEZONE_HOUR
CURRENT_DATELOCALTIMEZONE_MINUTE
CURRENT_TIMELOWERTO
CURRENT_TIMESTAMPMATCHTRAILING
CURRENT_USERMAXTRANSACTION
CURSORMINTRANSLATE
DATEMINUTETRANSLATION
DAYMODULETRIM
DEALLOCATEMONTHTRUE
DECNAMESUNION
DECIMALNATIONALUNIQUE
DECLARENATURALUNKNOWN
DEFAULTNCHARUPDATE
DEFERRABLENEXTUPPER
DEFERREDNOUSAGE
DELETENONEUSER
DESCNOTUSING
DESCRIBENULLVALUE
DESCRIPTORNULLIFVALUES
DIAGNOSTICSNUMERICVARCHAR
DISCONNECTOCTET_LENGTHVARYING
DISTINCTOFVIEW
DOMAINONWHEN
DOUBLEONLYWHENEVER
DROPOPENWHERE
ELSEOPTIONWITH
ENDORWORK
END-EXECORDERWRITE
ESCAPEOUTERYEAR
EXCEPTOUTPUTZONE
EXCEPTION  

将来的关键字

以下关键字可能会保留在将来的 SQL Server 版本中,作为将来要实现的新特性。注意,不要使用这些关键字作为标识符。

ABSOLUTEFOUNDPRESERVE
ACTIONFREEPRIOR
ADMINGENERALPRIVILEGES
AFTERGETREADS
AGGREGATEGLOBALREAL
ALIASGORECURSIVE
ALLOCATEGROUPINGREF
AREHOSTREFERENCING
ARRAYHOURRELATIVE
ASSERTIONIGNORERESULT
ATIMMEDIATERETURNS
BEFOREINDICATORROLE
BINARYINITIALIZEROLLUP
BITINITIALLYROUTINE
BLOBINOUTROW
BOOLEANINPUTROWS
BOTHINTSAVEPOINT
BREADTHINTEGERSCROLL
CALLINTERVALSCOPE
CASCADEDISOLATIONSEARCH
CASTITERATESECOND
CATALOGLANGUAGESECTION
CHARLARGESEQUENCE
CHARACTERLASTSESSION
CLASSLATERALSETS
CLOBLEADINGSIZE
COLLATIONLESSSMALLINT
COMPLETIONLEVELSPACE
CONNECTLIMITSPECIFIC
CONNECTIONLOCALSPECIFICTYPE
CONSTRAINTSLOCALTIMESQL
CONSTRUCTORLOCALTIMESTAMPSQLEXCEPTION
CORRESPONDINGLOCATORSQLSTATE
CUBEMAPSQLWARNING
CURRENT_PATHMATCHSTART
CURRENT_ROLEMINUTESTATE
CYCLEMODIFIESSTATEMENT
DATAMODIFYSTATIC
DATEMODULESTRUCTURE
DAYMONTHTEMPORARY
DECNAMESTERMINATE
DECIMALNATURALTHAN
DEFERRABLENCHARTIME
DEFERREDNCLOBTIMESTAMP
DEPTHNEWTIMEZONE_HOUR
DEREFNEXTTIMEZONE_MINUTE
DESCRIBENOTRAILING
DESCRIPTORNONETRANSLATION
DESTROYNUMERICTREAT
DESTRUCTOROBJECTTRUE
DETERMINISTICOLDUNDER
DICTIONARYONLYUNKNOWN
DIAGNOSTICSOPERATIONUNNEST
DISCONNECTORDINALITYUSAGE
DOMAINOUTUSING
DYNAMICOUTPUTVALUE
EACHPADVARCHAR
END-EXECPARAMETERVARIABLE
EQUALSPARAMETERSWHENEVER
EVERYPARTIALWITHOUT
EXCEPTIONPATHWORK
EXTERNALPOSTFIXWRITE
FLASEPREFIXYEAR
FIRSTPREORDERZONE
FLOATPREPARE 

Tags:

作者:佚名
分享到: 微信 更多