すべてのプロダクト
Search
ドキュメントセンター

Tablestore:テーブル情報のクエリ

最終更新日:Apr 30, 2026

Tablestore SDK for Go を使用して、テーブルのスキーマ、構成、ストリーム設定、サーバ側暗号化 (SSE)、予約スループット、セカンダリインデックスなどの情報をクエリします。

前提条件

作業を開始する前に、次の要件を満たしていることを確認してください。

API リファレンス

func (tableStoreClient *TableStoreClient) DescribeTable(request *DescribeTableRequest) (*DescribeTableResponse, error)

DescribeTableRequest パラメーター

TableName (必須) string:テーブル名。

サンプルコード

次の例では、test_table テーブルの情報をクエリします。

func DescribeTableSample(client *tablestore.TableStoreClient) {
    describeTableReq := new(tablestore.DescribeTableRequest)
    describeTableReq.TableName = "test_table"
    response, err := client.DescribeTable(describeTableReq)
    if err != nil {
        fmt.Println("Failed to describe table with error:", err)
    } else {
        // Get the schema of the table.
        tableMeta := response.TableMeta
        fmt.Printf("* Table name: %s \n", tableMeta.TableName)
        fmt.Println("* Primary key information (primary key type 1:INTEGER,2:STRING,3:BINARY)")
        for _, schemaEntry := range tableMeta.SchemaEntry {
            fmt.Printf("%s:%v \n", *schemaEntry.Name, *schemaEntry.Type)
        }
        fmt.Println("* Predefined column information (predefined column type 1:INTEGER,2:DOUBLE,3:BOOLEAN,4:STRING,5:BINARY)")
        for _, definedColumn := range tableMeta.DefinedColumns {
            fmt.Printf("%s:%v \n", definedColumn.Name, definedColumn.ColumnType)
        }

        // Get the configuration of the table.
        tableOption := response.TableOption
        fmt.Println("* Table configuration")
        fmt.Printf("Max versions: %d \n", tableOption.MaxVersion)
        fmt.Printf("Time to live (TTL): %d \n", tableOption.TimeToAlive)
        fmt.Printf("Max version offset: %d \n", tableOption.DeviationCellVersionInSec)
        fmt.Printf("Allow updates: %t \n", *tableOption.AllowUpdate)

        // Get the Stream settings of the table.
        streamDetails := response.StreamDetails
        fmt.Printf("* Stream enabled: %t \n", streamDetails.EnableStream)
        if streamDetails.EnableStream {
            fmt.Printf("Stream expiration time: %d \n", streamDetails.ExpirationTime)
        }

        // Get the server-side encryption (SSE) settings of the table.
        sseDetails := response.SSEDetails
        fmt.Printf("* SSE enabled: %t \n", sseDetails.Enable)
        if sseDetails.Enable {
            fmt.Printf("Encryption key type: %s \n", sseDetails.KeyType.String())
        }

        // Get the reserved throughput of the table.
        reservedThroughput := response.ReservedThroughput
        fmt.Println("* Reserved throughput")
        fmt.Printf("Reserved read throughput: %d \n", reservedThroughput.Readcap)
        fmt.Printf("Reserved write throughput: %d \n", reservedThroughput.Writecap)

        // Get the secondary index information.
        indexMetas := response.IndexMetas
        for _, indexMeta := range indexMetas {
            fmt.Printf("* Secondary index name: %s \n", indexMeta.IndexName)
            fmt.Printf("Primary key columns: %v \n", indexMeta.Primarykey)
            fmt.Printf("Predefined columns: %v \n", indexMeta.DefinedColumns)
            fmt.Printf("Secondary index type: %d (0:IT_GLOBAL_INDEX,1:IT_LOCAL_INDEX) \n", indexMeta.IndexType)
        }
    }
}

参考資料

時系列テーブル情報のクエリ