CREATE INDEX vs ALTER TABLE ADD INDEX – MySQLism还是SQL Standard?

前端之家收集整理的这篇文章主要介绍了CREATE INDEX vs ALTER TABLE ADD INDEX – MySQLism还是SQL Standard?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
刚遇到一个奇怪的问题,根据我创建索引的方式,需要索引名称.

http://dev.mysql.com/doc/refman/5.5/en/create-index.html

http://dev.mysql.com/doc/refman/5.5/en/alter-table.html

CREATE INDEX `random_name` ON `my_table` (`my_column`); # Requires an index name

ALTER TABLE `my_table` ADD INDEX (`my_column`); # Does not require an index name

在我看来,CREATE INDEX调用,不应该使索引名称成为必需.我想知道这是MysqLism还是sql标准?

解决方法

我认为sql标准根本​​不定义如何创建索引.

来自this Wikipedia page的报价:

Standardization

There is no standard about creating indexes because the ISO sql
Standard does not cover physical aspects. Indexes are one of the
physical parts of database conception among others like storage
(tablespace or filegroups). RDBMS vendors all give a CREATE INDEX
Syntax with some specific options which depends on functionalities
they provide to customers.

The Postgres manual seems to support this here:

There are no provisions for indexes in the sql standard.

More evidence under this related question on SO.

原文链接:https://www.f2er.com/mssql/80571.html

猜你在找的MsSQL相关文章