Search code examples
sqlansi-sql

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.

Anyone know for sure if this is a valid ANSI ISO SQL keyword?


Solution

  • There is no ANSI standard for SQL language used to create, alter, or manage indexes. So no, INDEX is not a keyword (reserved word) per ANSI standards.

    Kevin Kline specifically backs me up here in his book SQL in a Nutshell. 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. For example see IBM doc here for ALTER INDEX.

    This is also a handy list of the ANSI SQL reserved words - but only up to 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. According to ANSI a null does not equal a null; therefore a unique index should allow multiple null values since per ANSI they do not equal each other. 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. There may be other ANSI standards that have a similar effect on INDEX but nothing regarding the DDL surrounding them.