docs/en/integrations/cockroachdb/tools/cockroachdb-list-tables.md
The cockroachdb-list-tables tool retrieves a list of tables from a CockroachDB database. It provides detailed information about table structure, including columns, constraints, indexes, and foreign key relationships.
This tool is useful for:
{{< compatible-sources >}}
The tool accepts optional runtime parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
table_names | array | all tables | List of specific table names to retrieve |
output_format | string | "detailed" | Output format: "simple" or "detailed" |
sources:
my_cockroachdb:
type: cockroachdb
host: your-cluster.cockroachlabs.cloud
port: "26257"
user: myuser
password: mypassword
database: defaultdb
queryParams:
sslmode: require
tools:
list_all_tables:
type: cockroachdb-list-tables
source: my_cockroachdb
description: List all user tables in the database with their structure
{}
{
"table_names": ["users", "orders", "expenses"]
}
{
"output_format": "simple"
}
{
"table_name": "users",
"estimated_rows": 1000,
"size": "128 KB"
}
{
"table_name": "users",
"schema": "public",
"columns": [
{
"name": "id",
"type": "UUID",
"nullable": false,
"default": "gen_random_uuid()"
},
{
"name": "email",
"type": "STRING",
"nullable": false,
"default": null
},
{
"name": "created_at",
"type": "TIMESTAMP",
"nullable": false,
"default": "now()"
}
],
"primary_key": ["id"],
"indexes": [
{
"name": "users_pkey",
"columns": ["id"],
"unique": true,
"primary": true
},
{
"name": "users_email_idx",
"columns": ["email"],
"unique": true,
"primary": false
}
],
"foreign_keys": [],
"constraints": [
{
"name": "users_email_check",
"type": "CHECK",
"definition": "email ~* '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}$'"
}
]
}
The tool recognizes CockroachDB's recommended UUID primary key pattern:
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
...
);
For multi-region tables, the output includes locality information:
{
"table_name": "users",
"locality": "REGIONAL BY ROW",
"regions": ["us-east-1", "us-west-2", "eu-west-1"]
}
The tool shows parent-child relationships for interleaved tables (legacy feature):
{
"table_name": "order_items",
"interleaved_in": "orders"
}
Returns basic table information:
{
"table_names": ["users"],
"output_format": "simple"
}
Returns comprehensive table information:
{
"table_names": ["users", "orders"],
"output_format": "detailed"
}
| Field | Type | Description |
|---|---|---|
type | string | Must be cockroachdb-list-tables |
source | string | Name of the CockroachDB source to use |
description | string | Human-readable description for the LLM |
| Field | Type | Description |
|---|---|---|
authRequired | array | List of authentication services required |
The tool is ideal for helping AI assistants understand your database structure:
tools:
discover_schema:
type: cockroachdb-list-tables
source: my_cockroachdb
description: |
Use this tool first to understand the database schema before generating queries.
It shows all tables, their columns, data types, and relationships.
For databases with many tables, specify relevant tables:
{
"table_names": ["users", "orders", "products"],
"output_format": "detailed"
}
When you need just table names and sizes:
{
"output_format": "simple"
}
The tool automatically excludes system tables and schemas:
pg_catalog.* - PostgreSQL system cataloginformation_schema.* - SQL standard information schemacrdb_internal.* - CockroachDB internal tablespg_extension.* - PostgreSQL extension tablesOnly user-created tables in the public schema (and other user schemas) are returned.
tools:
list_tables:
type: cockroachdb-list-tables
source: my_cockroachdb
description: |
Lists all tables in the database with detailed schema information.
Use this tool to understand:
- What tables exist
- What columns each table has
- Data types and constraints
- Relationships between tables (foreign keys)
- Available indexes
Always call this tool before generating SQL queries to ensure
you use correct table and column names.
{}
This provides comprehensive schema information that helps AI assistants generate accurate SQL queries.
{
"table_names": ["users"],
"output_format": "detailed"
}
Perfect for understanding a specific table's structure, constraints, and relationships.
{
"output_format": "simple"
}
Gets a quick list of tables with basic statistics.
table_names reduces query timeThe tool handles common errors: