show_create_table
Retrieve the CREATE TABLE DDL statement for any table in Trino or Iceberg catalogs using catalog, schema, and table identifiers.
Instructions
Show the CREATE TABLE statement for a specific table
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| catalog | Yes | catalog name | |
| schema_name | Yes | schema name | |
| table | Yes | The name of the table |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/server.py:90-106 (handler)MCP tool handler function for show_create_table. Decorated with @mcp.tool(), it defines the tool interface with Pydantic Field schemas for parameters (catalog, schema_name, table) and delegates to the client implementation.
@mcp.tool(description="Show the CREATE TABLE statement for a specific table") def show_create_table( catalog: str = Field(description="catalog name "), schema_name: str = Field(description="schema name "), table: str = Field(description="The name of the table"), ) -> str: """Show the CREATE TABLE statement for a table. Args: catalog: catalog name schema_name: schema name table: The name of the table Returns: str: The CREATE TABLE statement """ return client.show_create_table(catalog, schema_name, table) - src/trino_client.py:172-192 (handler)Core implementation of show_create_table in TrinoClient class. Handles default catalog/schema resolution, executes the SQL query 'SHOW CREATE TABLE {catalog}.{schema}.{table}', parses the JSON result, and returns the CREATE TABLE statement string.
def show_create_table(self, catalog: str, schema: str, table: str) -> str: """Show the CREATE TABLE statement for a table. Args: schema (str): The schema name. If None, uses configured default. catalog (str): The catalog name. If None, uses configured default. table (str): The name of the table. Returns: str: The CREATE TABLE statement for the specified table. Raises: CatalogSchemaError: If either catalog or schema is not specified and not configured. """ catalog = catalog or self.config.catalog schema = schema or self.config.schema if not catalog or not schema: raise CatalogSchemaError query = f"SHOW CREATE TABLE {catalog}.{schema}.{table}" result = json.loads(self.execute_query(query)) return result[0]["Create Table"] if result else ""