Todos os produtos
Search
Central de documentação

Tablestore:Consultar as informações de índice de uma tabela

Última atualização: Jul 03, 2026

Execute a instrução show index para recuperar os metadados de índice de uma tabela, incluindo nomes, campos e tipos.

Nota

Para obter a referência completa da instrução show index, consulte Consultar as informações de índice de uma tabela.

Pré-requisitos

Inicialize um cliente do Tablestore. Para mais informações, consulte Inicializar um cliente do Tablestore.

Notas de uso

O recurso de consulta SQL é compatível com o Tablestore SDK for Java V5.13.0 ou superior. Ao utilizar esse recurso, verifique se você instalou uma versão compatível do Tablestore SDK for Java.

Parâmetros

Parâmetro

Descrição

query

Instrução SQL. Defina este parâmetro conforme o recurso desejado.

Exemplos

O exemplo a seguir executa show index in test_table para recuperar todos os metadados de índice da test_table. O conjunto de resultados inclui o schema e uma linha por campo de índice.

private static void showIndexDemo(SyncClient client) {
    // Submit the SQL request
    SQLQueryRequest request = new SQLQueryRequest("show index in test_table");
    SQLQueryResponse response = client.sqlQuery(request);

    // Print the result set schema
    SQLTableMeta tableMeta = response.getSQLResultSet().getSQLTableMeta();
    System.out.println("response table schema: " + tableMeta.getSchema());

    // Iterate over each row in the result set
    System.out.println("response resultset:");
    SQLResultSet resultSet = response.getSQLResultSet();
    while (resultSet.hasNext()) {
        SQLRow row = resultSet.next();
        System.out.println(row.getString("Table") + ", " + row.getLong("Non_unique") + ", " +
                           row.getString("Key_name") + ", " + row.getLong("Seq_in_index") + ", " +
                           row.getString("Column_name") + ", " + row.getString("Index_type") );
    }
}

Resposta de exemplo:

response table schema: [Table:STRING, Non_unique:INTEGER, Key_name:STRING, Seq_in_index:INTEGER, Column_name:STRING, Is_defined_column:STRING, Collation:STRING, Cardinality:INTEGER, Sub_part:INTEGER, Packed:STRING, Null:STRING, Index_type:STRING, Comment:STRING, Index_comment:STRING, Visible:STRING, Expression:STRING]
response resultset:
test_table, 0, PRIMARY, 1, pk,
test_table, 1, test_table_index, 1, pk, SearchIndex
test_table, 1, test_table_index, 2, bool_value, SearchIndex
test_table, 1, test_table_index, 3, double_value, SearchIndex
test_table, 1, test_table_index, 4, long_value, SearchIndex
test_table, 1, test_table_index, 5, string_value, SearchIndex

A linha do schema lista todas as colunas retornadas por show index. Cada linha subsequente representa um campo em um índice. No exemplo, a test_table possui um índice de chave primária (PRIMARY) e um índice de busca (test_table_index) que abrange cinco campos.

Referências