Get DDL (CREATE statement) for a Database Object
pg_get_ddlRetrieve the DDL (CREATE statement) for any PostgreSQL table, view, materialized view, function, or index. Generate SQL code to replicate object definitions across environments.
Instructions
Get the CREATE statement (DDL) for a table, view, materialized view, function, or index.
Args:
object_name: Name of the object (required)
schema: Schema name (default: public)
object_type: Type of object: 'table', 'view', 'matview', 'function', 'index' (default: 'table')
Returns: JSON: { schema, object_name, object_type, ddl: string } Markdown: formatted SQL code block
Useful for understanding table structure, reproducing objects in other environments, or code review.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"object_name": "<object_name>"
},
"name": "pg_get_ddl"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| object_name | Yes | Name of the object | |
| schema | No | PostgreSQL schema name (default: public) | public |
| object_type | No | Object type: 'table', 'view', 'matview', 'function', 'index' | table |