View table information¶
View the field definitions and row numbers of the table without returning the data rows in the table.
POST $CLOUDSIGMA_API_BASE/meta/table/info
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region.
Prepare personal access token and target workspace ID that can access the target workspace.
View database, select the database name.
Query the table and view list in the database and select the table name.
Prepare credentials with permissions on the target table SELECT. Workspace access or metadata visibility permissions cannot replace the SELECT permission.
Request body¶
Replace $CLOUDSIGMA_API_KEY, $WORKSPACE_ID, $DATABASE, $TABLE in the example with actual values.
curl -X POST "$CLOUDSIGMA_API_BASE/meta/table/info" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"db_name\": \"$DATABASE\",
\"table_name\": \"$TABLE\"
}"
This interface executes SELECT COUNT(*) to obtain the number of rows, which may generate statistics overhead for the entire table.
If you only need field definitions, use query table field list.
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
The name of the database where the table resides. |
|
string |
Yes |
The name of the table to view. |
Successful response¶
{
"code": 200,
"data": {
"columns": [
{
"name": "id",
"data_type": "INT",
"nullable": "NO",
"default_value": "",
"key_type": "PRI",
"comment": ""
}
],
"total": 1,
"rows": 42
}
}
Field |
Type |
Description |
|---|---|---|
|
integer |
200 on success. |
|
object |
table information. |
|
array of objects or null |
List of column definitions. It is null if there is no column record. |
|
integer |
Number of columns. |
|
integer |
The number of rows in the table, the data row itself is not returned. |
|
string |
Column name. |
|
string |
Data type. |
|
string |
Whether to allow null values. YES means allowed, NO means not allowed. |
|
string |
Default value string. SQL NULL and the true empty string default both return an empty string and cannot be distinguished by this field. |
|
string |
Key type. |
|
string |
Column notes. |
Error response¶
{
"code": 404,
"message": "对象不存在"
}
Field |
Type |
Description |
|---|---|---|
|
integer or string |
Error code or status code. |
|
string |
error message. |