问题
Suppose I created index with descending order
CREATE INDEX `MyTable.MyIndex`
USING BTREE ON `MyTable` (`DateFrom` DESC, `DateTo` DESC);
I want to get information about it from information_schema
.
According to documentation information_schema.statistics
table does the job.
However I can't find any information about column order for indexes (i.e. ASC
or DESC
).
How can I find that information?
回答1:
Where is it written in the documentation that the table statistics does the job ?
Furthermore, I found in the create index doc this:
An index_col_name specification can end with ASC or DESC.
These keywords are permitted for future extensions for specifying ascending or descending index value storage.
Currently, they are parsed but ignored; index values are always stored in ascending order.
回答2:
try this query ....
SELECT non_unique,
index_name,
seq_in_index,
column_name,
collation,
cardinality,
sub_part,
packed,
nullable,
index_type,
comment
FROM information_schema.STATISTICS
WHERE table_schema = schema()
AND table_name = 'MyTable'
ORDER BY index_name,
seq_in_index
来源:https://stackoverflow.com/questions/10947197/get-index-direction-from-information-schema-in-mysql