简体   繁体   English

'INDEX'是否有效的SQL ANSI ISO标准关键字/保留字?

[英]Is 'INDEX' valid SQL ANSI ISO standard keyword / reserved word?

I've done some research on whether 'INDEX' is a keyword in ANSI SQL but I have not had any luck, especially with the 2008 and the 2011 standard. 我已经做过一些关于'INDEX'是否是ANSI SQL中的关键字的研究,但我没有运气,特别是2008和2011标准。

Anyone know for sure if this is a valid ANSI ISO SQL keyword? 任何人都知道这是否是一个有效的ANSI ISO SQL关键字?

There is no ANSI standard for SQL language used to create, alter, or manage indexes. 用于创建,更改或管理索引的SQL语言没有ANSI标准。 So no, INDEX is not a keyword (reserved word) per ANSI standards. 所以不,INDEX不是ANSI标准的关键字(保留字)。

Kevin Kline specifically backs me up here in his book SQL in a Nutshell . Kevin Kline在他的“ 果壳中的SQL”一书中特别支持我。 He points this out as one of the reasons the syntax for creating indexes varies greatly among vendors. 他指出这是创建索引的语法在供应商之间差异很大的原因之一。

As further circumstantial evidence you'll also note a variety of vendors mention in their SQL documentation that statements regarding INDEXs are extensions to the ANSI standard. 作为进一步的间接证据,您还会注意到各种供应商在其SQL文档中提到有关INDEX的语句是ANSI标准的扩展。 For example see IBM doc here for ALTER INDEX . 例如,请参阅此处的IBM doc for ALTER INDEX

This is also a handy list of the ANSI SQL reserved words - but only up to 2003. 这也是ANSI SQL保留字的一个方便列表 - 但仅限于2003。


As a side note: the only time I've ever seen ANSI mentioned at all with regards to indexes is when talking about how a unique index (often simply a unique constraint) treats null values. 作为旁注:我曾经见过ANSI在索引方面提到的唯一一次是在谈论唯一索引(通常只是一个唯一约束)如何处理空值时。 According to ANSI a null does not equal a null; 根据ANSI,null不等于null; therefore a unique index should allow multiple null values since per ANSI they do not equal each other. 因此,唯一索引应允许多个空值,因为每个ANSI它们彼此不相等。 Some engines follow this rule - others do not. 有些引擎遵循这条规则 - 其他引擎则没有。 The ANSI standard in this case only refers to whether two nulls are equal or unique... the standard has nothing to do with the index. 在这种情况下,ANSI标准仅指两个空值是相等还是唯一...标准与索引无关。 There may be other ANSI standards that have a similar effect on INDEX but nothing regarding the DDL surrounding them. 可能有其他ANSI标准对INDEX有类似的影响,但没有关于它们周围的DDL。

Indexes are purposely omitted from the SQL standard because not all data sources that could be targeted using SQL support any concept of 'index'. SQL标准中特意省略了索引,因为并非所有可以使用SQL定位的数据源都支持“index”的任何概念。 For example, in MS Access SQL one can use CREATE TABLE syntax to create a new MS Excel workbook containing what SQL considers to be a 'table' but which Excel considers to be a 'Named Range' and creating an Access table index on an Excel Range makes no sense. 例如,在MS Access SQL中,可以使用CREATE TABLE语法创建一个新的MS Excel工作簿,其中包含SQL认为是“表”但Excel认为是“命名范围”并在Excel上创建Access表索引范围毫无意义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM