Database Schema
db_schemaRetrieve the live PostgreSQL schema with column types, constraints, indexes, and foreign key relationships. Use it to verify column details and structure before building queries or debugging errors.
Instructions
Returns the full database schema with column-level detail: every table's columns with their data types, nullability, defaults, constraints (primary key, unique, check), indexes, and foreign key relationships presented as a relationship diagram. This is introspected live from PostgreSQL's information_schema, so it always reflects the current state of the database.
When to use:
When you need column-level detail beyond what db_overview provides.
Before constructing queries with specific columns, to verify column names and types.
When the user asks about table structure, constraints, or relationships.
When debugging query errors related to column types or constraints.
Behavioral notes:
Schema is fetched fresh on every call (not cached) to catch DDL changes.
Only schemas listed in PG_SCHEMAS are included (default: public).
The relationship diagram shows foreign keys between tables, useful for JOIN queries.
Returns: JSON with tables (each containing columns with type, nullable, default, constraints), indexes, and a relationships array.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Name of the database to query (from pgautopilot.json). Omit to use the current default database. |