Formatting code for MysqlIndex
{{parent page="MySQL"}}
=== Create index ===
Indexes can be created by
%%(sql)
create index INDEX_NAME on TABLE_NAME (COL1(10) ASC,COL2(30) DESC);
# create an index on COL1 using first 10 bytes in acceding order, and COL2 using first 30 bytes in descending order.
%%
=== Query existing indexes ===
%%(sql)
show index from TABLE_NAME;
%%
=== Drop an index ===
%%(sql)
drop index INDEX_NAME on TABLE_NAME;
%%
=== Rebuild an index ===
%%(sql)
repair table xxx.table1 quick;
%%
=== Locate indexes ===
%%(sql)
select TABLE_SCHEMA, TABLE_NAME, INDEX_NAME, INDEX_TYPE from statistics;
%%
=== Create index ===
Indexes can be created by
%%(sql)
create index INDEX_NAME on TABLE_NAME (COL1(10) ASC,COL2(30) DESC);
# create an index on COL1 using first 10 bytes in acceding order, and COL2 using first 30 bytes in descending order.
%%
=== Query existing indexes ===
%%(sql)
show index from TABLE_NAME;
%%
=== Drop an index ===
%%(sql)
drop index INDEX_NAME on TABLE_NAME;
%%
=== Rebuild an index ===
%%(sql)
repair table xxx.table1 quick;
%%
=== Locate indexes ===
%%(sql)
select TABLE_SCHEMA, TABLE_NAME, INDEX_NAME, INDEX_TYPE from statistics;
%%