Help Center/ GaussDB/ API Reference/ APIs (Recommended)/ Diagnostics and Optimization/ Querying the Definition Information of a Specified Table
Updated on 2025-10-20 GMT+08:00

Querying the Definition Information of a Specified Table

Function

This API is used to query the definition information of a specified table. Before calling this API:

Debugging

You can debug this API in API Explorer.

URI

GET /v3/{project_id}/instances/{instance_id}/list-table-definition

Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Definition

Project ID of a tenant in a region.

To obtain the value, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain 32 characters. Only letters and digits are allowed.

Default Value

N/A

instance_id

Yes

Definition

Instance ID, which uniquely identifies an instance.

Constraints

N/A

Range

The value can contain 36 characters. Only letters and digits are allowed.

Default Value

N/A

Table 2 Query parameters

Parameter

Mandatory

Type

Description

database_name

Yes

String

Definition

Database name.

Constraints

N/A

Range

N/A

Default Value

N/A

schema_name

No

String

Definition

Schema name.

Constraints

N/A

Range

N/A

Default Value

N/A

table_name

Yes

String

Definition

Table name.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token.

You can obtain the token by calling the IAM API used to obtain a user token.

The value of X-Subject-Token in the response header is the token value.

Constraints

N/A

Range

N/A

Default Value

N/A

X-Language

No

String

Definition

Language.

Constraints

N/A

Range

  • zh-cn
  • en-us

Default Value

en-us

Response Parameters

Table 4 Response body parameters

Parameter

Type

Description

table_definitions

Array of SchemaTableDefinition

Definition

Database table definition information.

For details, see Table 5.

Table 5 SchemaTableDefinition

Parameter

Type

Description

table_definition

String

Definition

Database table definition information.

Range

N/A

schema_name

String

Definition

Schema name.

Range

N/A

Example Request

Querying the definition information of a specified table

GET https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/3d39c18788b54a919bab633874c159dfin14/instances/3d39c18788b54a919bab633874c159dfin01/list-table-definition?database_name=postgres&table_name=t1&schema_name=public

Example Response

{
  "table_definitions": [
    {
      "schema_name": "public",
      "table_definition": "SET search_path = public;\nCREATE TABLE sbtest178 (\n    id integer NOT NULL,\n    k integer DEFAULT 0 NOT NULL,\n    c character(120) DEFAULT ''::bpchar NOT NULL,\n    pad character(60) DEFAULT ''::bpchar NOT NULL\n)\nWITH (orientation=row, compression=no, storage_type=USTORE, segment=off)\nDISTRIBUTE BY HASH(id)\nTO GROUP group_version_20250429_155518_878976;\nCREATE INDEX k_178 ON sbtest178 USING ubtree (k) WITH (storage_type=USTORE) TABLESPACE pg_default;\nALTER TABLE sbtest178 ADD CONSTRAINT sbtest178_pkey PRIMARY KEY USING ubtree  (id) WITH (storage_type=USTORE);"
    }
  ]
}

Status Codes

Error Codes

For details, see Error Codes.