微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/mssql/80571.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐