show_create_table
Retrieve the CREATE TABLE SQL statement for a specific table in an Alibaba Cloud RDS database to understand its structure and schema.
Instructions
show create table db_name.table_name
Args:
dbinstance_id (str): The ID of the RDS instance.
region_id(str): the region id of instance.
db_name(str): the db name for table.
table_name(str): the table name.
Returns:
the sql result.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region_id | Yes | ||
| dbinstance_id | Yes | ||
| db_name | Yes | ||
| table_name | Yes |
Implementation Reference
- The MCP tool handler for 'show_create_table'. It uses DBService to connect to an Alibaba Cloud RDS instance (specified by region_id and dbinstance_id) and the given database (db_name), then executes the MySQL SQL command 'SHOW CREATE TABLE db_name.table_name' to retrieve and return the CREATE TABLE statement for the specified table.@mcp.tool(annotations=READ_ONLY_TOOL) async def show_create_table( region_id: str, dbinstance_id: str, db_name: str, table_name: str ) -> str: """ show create table db_name.table_name Args: dbinstance_id (str): The ID of the RDS instance. region_id(str): the region id of instance. db_name(str): the db name for table. table_name(str): the table name. Returns: the sql result. """ try: async with DBService(region_id, dbinstance_id, db_name) as service: return await service.execute_sql(f"show create table {db_name}.{table_name}") except Exception as e: logger.error(f"Error occurred: {str(e)}") raise e