You can execute the SHOW INDEX statement to query the index information about tables.
Note For more information about the show index statement, see Query the index information about a table.
Prerequisites
- An OTSClient instance is initialized. For more information, see initialization.
- A mapping table is created. For more information, see Create mapping tables.
Parameters
Parameter | Description |
query | The SQL statement. Specify the parameter based on the required feature. |
Example
Execute the show index in test_table
statement to query index information about the table named test_table.
[[('Table', 'test_table'), ('Non_unique', 0), ('Key_name', 'PRIMARY'), ('Seq_in_index', 1), ('Column_name', 'pk'), ('Is_defined_column', None), ('Search_type', ''), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None), ('Packed', None), ('Null', ''), ('Index_type', ''), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')], [('Table', 'test_table'), ('Non_unique', 1), ('Key_name', 'test_table_index'), ('Seq_in_index', 1), ('Column_name', 'pk'), ('Is_defined_column', 'NO'), ('Search_type', 'KEYWORD'), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None), ('Packed', None), ('Null', 'YES'), ('Index_type', 'SearchIndex'), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')], [('Table', 'test_table'), ('Non_unique', 1), ('Key_name', 'test_table_index'), ('Seq_in_index', 2), ('Column_name', 'string_value'), ('Is_defined_column', 'NO'), ('Search_type', 'KEYWORD'), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None), ('Packed', None), ('Null', 'YES'), ('Index_type', 'SearchIndex'), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')], [('Table', 'test_table'), ('Non_unique', 1), ('Key_name', 'test_table_index'), ('Seq_in_index', 3), ('Column_name', 'bool_value'), ('Is_defined_column', 'NO'), ('Search_type', 'BOOLEAN'), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None), ('Packed', None), ('Null', 'YES'), ('Index_type', 'SearchIndex'), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')], [('Table', 'test_table'), ('Non_unique', 1), ('Key_name', 'test_table_index'), ('Seq_in_index', 4), ('Column_name', 'double_value'), ('Is_defined_column', 'NO'), ('Search_type', 'DOUBLE'), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None), ('Packed', None), ('Null', 'YES'), ('Index_type', 'SearchIndex'), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')], [('Table', 'test_table'), ('Non_unique', 1), ('Key_name', 'test_table_index'), ('Seq_in_index', 5), ('Column_name', 'long_value'), ('Is_defined_column', 'NO'), ('Search_type', 'LONG'), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None), ('Packed', None), ('Null', 'YES'), ('Index_type', 'SearchIndex'), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')]]
The following figure shows the schema of the search index named test_table_index that is created in the table named test_table.
The following output is returned:
[[('Table', 'test_table'), ('Non_unique', 0), ('Key_name', 'PRIMARY'), ('Seq_in_index', 1), ('Column_name', 'pk'),('Is_defined_column', None), ('Search_type', ''), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None),('Packed', None), ('Null', ''), ('Index_type', ''), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'),('Expression', 'NULL')],
[('Table', 'test_table'), ('Non_unique', 1), ('Key_name', 'test_table_index'), ('Seq_in_index', 1), ('Column_name', 'pk'), ('Is_defined_column', 'NO'), ('Search_type', 'KEYWORD'), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None), ('Packed', None), ('Null', 'YES'), ('Index_type', 'SearchIndex'), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')],
[('Table', 'test_table'), ('Non_unique', 1), ('Key_name', 'test_table_index'), ('Seq_in_index', 2), ('Column_name','string_value'), ('Is_defined_column', 'NO'), ('Search_type', 'KEYWORD'), ('Collation', 'A'), ('Cardinality', 0),('Sub_part', None), ('Packed', None), ('Null', 'YES'), ('Index_type', 'SearchIndex'), ('Comment', ''),('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')],
[('Table', 'test_table'), ('Non_unique', 1), ('Key_name', 'test_table_index'), ('Seq_in_index', 3), ('Column_name', 'bool_value'), ('Is_defined_column', 'NO'), ('Search_type', 'BOOLEAN'), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None), ('Packed', None), ('Null', 'YES'), ('Index_type', 'SearchIndex'), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')],
[('Table', 'test_table'), ('Non_unique', 1), ('Key_name', 'test_table_index'), ('Seq_in_index', 4), ('Column_name', 'double_value'), ('Is_defined_column', 'NO'), ('Search_type', 'DOUBLE'), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None), ('Packed', None), ('Null', 'YES'), ('Index_type', 'SearchIndex'), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')],
[('Table', 'test_table'), ('Non_unique', 1), ('Key_name', 'test_table_index'), ('Seq_in_index', 5), ('Column_name', 'long_value'), ('Is_defined_column', 'NO'), ('Search_type', 'LONG'), ('Collation', 'A'), ('Cardinality', 0), ('Sub_part', None), ('Packed', None), ('Null', 'YES'), ('Index_type', 'SearchIndex'), ('Comment', ''), ('Index_comment', ''), ('Visible', 'YES'), ('Expression', 'NULL')]]