Skip to main content
The schema command provides powerful tools to explore your database structure without writing SQL. View tables, inspect column definitions, and visualize your entire schema as a tree.

Subcommands

schema list

List all tables in a database connection with row counts.
queryly schema list <connection>
connection
string
required
Name of the saved database connection
Example:
$ queryly schema list MyApp
Fetching schema...
┌──────────────────┬───────────┐
 Table Name      Rows
├──────────────────┼───────────┤
 users     1,234
 orders     5,678
 products       890
 categories        45
└──────────────────┴───────────┘

Total: 4 table(s)
Output Details:
  • Table Name: Name of each table in the database
  • Rows: Total row count (formatted with thousands separators)
  • Total: Summary count of all tables
Row counts are retrieved efficiently using COUNT(*) queries. For very large tables, this may take a moment.
No Tables Found:
$ queryly schema list EmptyDB
Fetching schema...
! No tables found in the database.

schema info

Show detailed information about a specific table including all columns, data types, nullability, and primary keys.
queryly schema info <connection> <table>
connection
string
required
Name of the saved database connection
table
string
required
Name of the table to inspect
Example:
$ queryly schema info MyApp users
Fetching table info...
Table: users

Columns:
┌─────────────┬──────────────┬─────────────┬────────────────┬───────────────┐
 Column Name Data Type Is Nullable Is Primary Key Default Value
├─────────────┼──────────────┼─────────────┼────────────────┼───────────────┤
 id INTEGER     No       PK
 name TEXT     No
 email TEXT     No
 created_at DATETIME     Yes CURRENT_TIME
 is_active BOOLEAN     Yes 1
└─────────────┴──────────────┴─────────────┴────────────────┴───────────────┘

Total: 5 column(s)
Column Information:
FieldDescription
Column NameThe name of the column
Data TypeDatabase-specific data type (INTEGER, TEXT, VARCHAR, etc.)
Is NullableWhether the column accepts NULL values (Yes/No)
Is Primary KeyMarked with “PK” if column is part of the primary key
Default ValueDefault value assigned to new rows (empty if none)
Common SQLite data types:
  • INTEGER - Whole numbers
  • TEXT - Text strings
  • REAL - Floating point numbers
  • BLOB - Binary data
  • NUMERIC - General numeric
Table names are case-sensitive on some database systems (PostgreSQL, MySQL on Linux). Use the exact casing shown in schema list.

schema tree

Display the entire database schema as a hierarchical tree showing all tables and their columns.
queryly schema tree <connection>
connection
string
required
Name of the saved database connection
Example:
$ queryly schema tree MyApp
Loading schema...
MyApp (SQLite)
├── users (1,234 rows)
   ├── id INTEGER (PK)
   ├── name TEXT
   ├── email TEXT
   ├── created_at DATETIME (nullable)
   └── is_active BOOLEAN (nullable)
├── orders (5,678 rows)
   ├── id INTEGER (PK)
   ├── user_id INTEGER
   ├── total DECIMAL
   ├── status VARCHAR (nullable)
   └── created_at TIMESTAMP
├── products (890 rows)
   ├── id INTEGER (PK)
   ├── name VARCHAR
   ├── price DECIMAL
   ├── category_id INTEGER (nullable)
   └── description TEXT (nullable)
└── categories (45 rows)
    ├── id INTEGER (PK)
    └── name VARCHAR
Tree Structure:
  • Root: Connection name and database type
  • Tables: Each table shows name and row count
  • Columns: Each column shows:
    • Column name
    • Data type
    • (PK) marker for primary keys
    • (nullable) marker for nullable columns
The tree view is perfect for:
  • Getting a quick overview of your entire schema
  • Understanding table relationships by spotting foreign key patterns
  • Finding all nullable columns at a glance
  • Identifying primary keys across all tables
Large Schemas: For databases with many tables or columns, the tree can be quite tall. The output scrolls naturally in your terminal.
$ queryly schema tree ProductionDB
Loading schema...
ProductionDB (PostgreSQL)
├── table_1 (10,000 rows)
   ├── ...
├── table_2 (25,000 rows)
   ├── ...
├── table_3 (5,000 rows)
   ├── ...
# ... and so on

Usage Examples

Exploring a New Database

# Step 1: See what tables exist
queryly schema list MyDB

# Step 2: Inspect specific table structure
queryly schema info MyDB users

# Step 3: View full schema tree
queryly schema tree MyDB

Finding Primary Keys

# Quick way to see all primary keys across tables
queryly schema tree MyDB
# Look for (PK) markers in the output

Checking Table Structure Before Queries

# See exact column names and types before writing SQL
queryly schema info MyDB orders

# Then write your query with confidence
queryly data query MyDB
SQL> SELECT id, user_id, total FROM orders WHERE total > 100

Comparing Databases

queryly schema tree DevDB
# Compare output...

Database-Specific Behavior

Schema Detection:
  • Lists all user-created tables (excludes sqlite_* system tables)
  • Automatically detects primary keys from table definitions
  • Shows AUTOINCREMENT for integer primary keys
Limitations:
  • SQLite doesn’t have built-in schema support (single database only)
  • Foreign keys are stored as table constraints, not shown in column info

Error Messages

ErrorMeaningSolution
Connection 'name' not foundNo saved connection with that nameUse connect list to see available connections
No tables found in the databaseDatabase exists but has no tablesCreate tables or verify you’re connecting to the right database
No columns found in the tableTable name doesn’t existCheck table name with schema list (case-sensitive)
Invalid data commandIncorrect command syntaxVerify command format: schema <subcommand> <args>

Performance Considerations

Row Counts: Computing row counts with COUNT(*) can be slow on very large tables (millions of rows). The schema commands use this to provide accurate counts.
Tree View: For databases with 100+ tables, consider using schema list first to narrow down which tables you want to inspect with schema info.

Next Steps

Browse Table Data

After exploring the schema, browse actual data with data browse

Run Queries

Use schema knowledge to write queries with data query

Build docs developers (and LLMs) love