刚遇到一个奇怪的问题,根据我创建索引的方式,需要索引名称.
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
解决方法
我认为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.