Query information about a table

更新时间:
复制 MD 格式

You can execute the DESCRIBE statement to query the information about tables, such as the field names and field types.

Note

For more information about the DESCRIBE statement, see Query information about tables.

Prerequisites

A Tablestore client is initialized. For more information, see Initialize a Tablestore client.

Usage notes

The SQL query feature is supported by Tablestore SDK for PHP V5.1.0 and later. When you use the SQL query feature, make sure that a supported version of Tablestore SDK for PHP is installed.

For information about the version history of Tablestore SDK for PHP, see Version history of Tablestore SDK for PHP.

Examples

The following sample code provides an example on how to execute the DESCRIBE `tableName`; statement to query information about a table named tableName:

$request = array(
    'query' => 'DESCRIBE `tableName`;',
);
$response = $otsClient->sqlQuery ($request);
$sqlRows = $response['sql_rows'];
print json_encode($sqlRows, JSON_PRETTY_PRINT);

References

  • To use a mapping table to query data that meets specific conditions, execute the SELECT statement. For more information, see Query data.

  • To update the attribute column of a mapping table after an attribute column of the data table is changed, execute the ALTER TABLE statement. For more information, see Update attribute columns of mapping tables.

  • To delete a mapping table, execute the DROP MAPPING TABLE statement. For more information, see Delete mapping tables.