Rebuild the CREATE statement of an object
pg_get_ddlRebuilds the CREATE DDL for PostgreSQL tables, views, functions, sequences, types, indexes, triggers, and schemas, so you can copy structures or review definitions.
Instructions
Rebuild the CREATE statement (DDL, as SQL text) of a table, view, materialized view, function, procedure, sequence, type (enum, domain, composite, range), index, trigger or schema.
A table comes with its columns (types, defaults, identity and generated columns, NOT
NULL), constraints, PARTITION BY / PARTITION OF, INHERITS, indexes, comments, triggers,
row level security and policies. Names are always schema-qualified. Owners and GRANTs
are not included. name is name or schema.name; a function accepts a signature such
as shop.order_total(bigint). Use it to copy a structure or to review how an object was
defined.
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": {
"name": "<name>"
},
"name": "pg_get_ddl"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | table | |
| name | Yes | ||
| connection | No |