docs/en/integrations/cockroachdb/tools/cockroachdb-list-schemas.md
The cockroachdb-list-schemas tool retrieves a list of schemas (namespaces) in a CockroachDB database. Schemas are used to organize database objects such as tables, views, and functions into logical groups.
This tool is useful for:
{{< compatible-sources >}}
To list schemas, the user needs:
CONNECT privilege on the databaseTo query objects within schemas, the user needs:
USAGE privilege on the schemasources:
my_cockroachdb:
type: cockroachdb
host: your-cluster.cockroachlabs.cloud
port: "26257"
user: myuser
password: mypassword
database: defaultdb
queryParams:
sslmode: require
tools:
list_schemas:
type: cockroachdb-list-schemas
source: my_cockroachdb
description: List all schemas in the database
{}
No parameters are required. The tool automatically lists all user-defined schemas.
The tool returns a list of schemas with the following information:
[
{
"catalog_name": "defaultdb",
"schema_name": "public",
"is_user_defined": true
},
{
"catalog_name": "defaultdb",
"schema_name": "analytics",
"is_user_defined": true
}
]
| Field | Type | Description |
|---|---|---|
catalog_name | string | The database (catalog) name |
schema_name | string | The schema name |
is_user_defined | boolean | Whether this is a user-created schema (excludes system schemas) |
| Field | Type | Description |
|---|---|---|
type | string | Must be cockroachdb-list-schemas |
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 |
CockroachDB includes several standard schemas:
public: The default schema for user objectspg_catalog: PostgreSQL system catalog (excluded from results)information_schema: SQL standard metadata views (excluded from results)crdb_internal: CockroachDB internal metadata (excluded from results)pg_extension: PostgreSQL extension objects (excluded from results)The tool filters out system schemas and only returns user-defined schemas.
CREATE SCHEMA analytics;
-- Create table in specific schema
CREATE TABLE analytics.revenue (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
amount DECIMAL(10,2),
date DATE
);
-- Query from specific schema
SELECT * FROM analytics.revenue;
The search path determines which schemas are searched for unqualified object names:
-- Show current search path
SHOW search_path;
-- Set search path
SET search_path = analytics, public;
Schemas are commonly used for multi-tenant applications:
-- Create schema per tenant
CREATE SCHEMA tenant_acme;
CREATE SCHEMA tenant_globex;
-- Create same table structure in each schema
CREATE TABLE tenant_acme.orders (...);
CREATE TABLE tenant_globex.orders (...);
The cockroachdb-list-schemas tool helps discover all tenant schemas:
tools:
list_tenants:
type: cockroachdb-list-schemas
source: my_cockroachdb
description: |
List all tenant schemas in the database.
Each schema represents a separate tenant's data namespace.
Group related tables into schemas:
CREATE SCHEMA sales;
CREATE SCHEMA inventory;
CREATE SCHEMA hr;
CREATE TABLE sales.orders (...);
CREATE TABLE inventory.products (...);
CREATE TABLE hr.employees (...);
Use clear, descriptive schema names:
tenant_, app_)Schemas enable fine-grained access control:
-- Grant access to specific schema
GRANT USAGE ON SCHEMA analytics TO analyst_role;
GRANT SELECT ON ALL TABLES IN SCHEMA analytics TO analyst_role;
-- Revoke access
REVOKE ALL ON SCHEMA hr FROM public;
tools:
list_schemas:
type: cockroachdb-list-schemas
source: my_cockroachdb
description: List all schemas first
list_tables:
type: cockroachdb-list-tables
source: my_cockroachdb
description: |
List tables in the database.
Use list_schemas first to understand schema organization.
cockroachdb-list-schemas to discover schemascockroachdb-list-tables to see tables in each schemaschema.tabletools:
discover_schemas:
type: cockroachdb-list-schemas
source: my_cockroachdb
description: |
Discover how the database is organized into schemas.
Use this to understand the logical grouping of tables.
tools:
list_tenant_schemas:
type: cockroachdb-list-schemas
source: my_cockroachdb
description: |
List all tenant schemas (each tenant has their own schema).
Schema names follow the pattern: tenant_<company_name>
tools:
audit_schemas:
type: cockroachdb-list-schemas
source: my_cockroachdb
description: |
Audit existing schemas before migration.
Identifies all schemas that need to be migrated.
CockroachDB includes PostgreSQL-compatible system schemas plus CockroachDB-specific ones:
crdb_internal.*: CockroachDB internal metadata and statisticspg_catalog.*: PostgreSQL system cataloginformation_schema.*: SQL standard information schemaThese are automatically filtered from the results.
The is_user_defined field helps distinguish:
true: User-created schemasfalse: System schemas (already filtered out)The tool handles common errors: