Browse, query, and export table data with the data command
The data command provides powerful tools for viewing, querying, and exporting your database data. Browse tables with pagination, run interactive SQL queries, and export data to CSV or JSON formats.
$ queryly data browse MyApp usersBrowsing Table: users (1,234 rows, 25 pages)┌─────┬──────────────┬──────────────────────┬─────────────────────┬───────────┐│ id │ name │ email │ created_at │ is_active │├─────┼──────────────┼──────────────────────┼─────────────────────┼───────────┤│ 1 │ Alice Smith │[email protected] │ 2024-01-15 10:30:00 │ 1 ││ 2 │ Bob Jones │[email protected] │ 2024-01-16 14:20:00 │ 1 ││ 3 │ Carol Lee │[email protected] │ 2024-01-17 09:15:00 │ 0 ││ ... │ ... │ ... │ ... │ ... ││ 50 │ Emma Wilson │[email protected] │ 2024-02-10 16:45:00 │ 1 │└─────┴──────────────┴──────────────────────┴─────────────────────┴───────────┘Showing 50 of 1,234 row(s) | Query time: 12.34ms────────────────────────────────────────────────────────────── Page 1 of 25 Rows 1–50 of 1,234──────────────────────────────────────────────────────────────Commands: [N]ext • [P]rev • [G]o to page • [Q]uit──────────────────────────────────────────────────────────────Command>
Navigation Commands:
Command
Description
n
Go to next page
p
Go to previous page
g or go
Go to specific page number (prompts for page)
h or help
Show help menu
q
Quit and return to terminal
Interactive Navigation:
# Go to next pageCommand> n# Now viewing page 2...# Go to previous pageCommand> p# Back to page 1...# Jump to specific pageCommand> gEnter page number (1-25): 10# Now viewing page 10...# Quit browsingCommand> qExited browse mode.
Data Display:
Shows up to 50 rows per page
NULL values displayed as NULL
Long text values truncated to 50 characters with ...
Automatic column width adjustment
Row numbers and totals in footer
Browse mode clears the screen for each page to provide a clean viewing experience. Use arrow keys aren’t supported - type commands instead.
Performance: The first page loads instantly. Jumping to later pages requires offsetting rows, which may be slower on very large tables.
$ queryly data query MyAppQuery Mode - MyAppEnter SQL queries. Type 'exit' to quit.SQL> SELECT COUNT(*) FROM users┌────────────┐│ COUNT(*) │├────────────┤│ 1234 │└────────────┘Showing 1 of 1 row(s) | Query time: 2.34msSQL> SELECT name, email FROM users WHERE is_active = 1 LIMIT 5┌──────────────┬──────────────────────┐│ name │ email │├──────────────┼──────────────────────┤│ Alice Smith │[email protected] ││ Bob Jones │[email protected] ││ David Kim │[email protected] ││ Emma Wilson │[email protected] ││ Frank Chen │[email protected] │└──────────────┴──────────────────────┘Showing 5 of 5 row(s) | Query time: 1.23msSQL> SELECT category_id, COUNT(*) as product_count, AVG(price) as avg_price FROM products GROUP BY category_id┌─────────────┬───────────────┬───────────┐│ category_id │ product_count │ avg_price │├─────────────┼───────────────┼───────────┤│ 1 │ 45 │ 29.99 ││ 2 │ 32 │ 54.99 ││ 3 │ 18 │ 19.99 │└─────────────┴───────────────┴───────────┘Showing 3 of 3 row(s) | Query time: 8.45msSQL> exitExited query mode.
Query Features:
SELECT Queries
INSERT/UPDATE/DELETE
CREATE/ALTER/DROP
Multi-line Queries
Run any SELECT query to retrieve data:
-- Simple selectSELECT * FROM users-- With WHERE clauseSELECT name, email FROM users WHERE is_active = 1-- With JOINsSELECT u.name, o.totalFROM users u JOIN orders o ON u.id = o.user_id-- With aggregationsSELECT COUNT(*), AVG(total) FROM orders-- With GROUP BYSELECT status, COUNT(*) FROM orders GROUP BY status
Results are formatted in a clean table with:
Column headers
Aligned data
Row count
Execution time in milliseconds
Modify data with INSERT, UPDATE, or DELETE:
-- Insert new rowINSERT INTO users (name, email) VALUES ('John Doe', '[email protected]')-- Update existing rowsUPDATE users SET is_active = 0WHERE id = 5-- Delete rowsDELETE FROM users WHERE created_at < '2023-01-01'
Data modification queries are executed immediately and cannot be undone. Make sure you’re connected to the right database before running UPDATE or DELETE commands.
Success output:
No data found.Query time: 5.23ms
Run DDL (Data Definition Language) commands:
-- Create tableCREATE TABLE products ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, price DECIMAL(10,2))-- Add columnALTER TABLE users ADD COLUMN phone TEXT-- Create indexCREATE INDEX idx_email ON users(email)-- Drop tableDROP TABLE old_table
DDL commands execute successfully but don’t return result sets. You’ll see:
No data found.Query time: 15.67ms
While Queryly’s query mode is line-based, you can write multi-line SQL by using your terminal’s line continuation:
SQL> SELECT u.name, COUNT(o.id) as order_count, SUM(o.total) as total_spent FROM users u LEFT JOIN orders o ON u.id = o.user_id GROUP BY u.id ORDER BY total_spent DESC LIMIT 10
For complex queries, consider writing them in a text editor first, then paste them into the SQL prompt.
Error Handling:
SQL> SELECT * FROM nonexistent_table✗ Error: no such table: nonexistent_tableSQL> SELECT invalid syntax✗ Error: near "syntax": syntax error
Errors are displayed in red and don’t exit query mode - you can immediately try again.Exiting:
SQL> exitExited query mode.
Type exit at the SQL prompt to return to your terminal.
Large Tables: Exporting very large tables (millions of rows) can take time and produce large files. Monitor disk space and consider filtering data with a custom query first.
Custom Exports: For filtered exports, use data query to run a SELECT query and manually save results, or pipe query output to a file using your shell.
$ queryly data query MyAppSQL> SELECT * FROM orders WHERE status = 'completed' AND created_at > '2024-01-01'# Copy results manually or use shell redirection:# Better: Use custom SQL in your application
-- SQLite-specific featuresSELECT * FROM sqlite_master WHERE type='table'-- Date functionsSELECT date('now'), datetime('now', '+1 day')-- AUTOINCREMENTSELECT last_insert_rowid()
-- PostgreSQL-specific featuresSELECT * FROM pg_tables WHERE schemaname = 'public'-- JSON queriesSELECT data->>'name' FROM users WHERE data @> '{"active": true}'-- Array functionsSELECT array_agg(name) FROM users-- Window functionsSELECT name, ROW_NUMBER() OVER (ORDER BY created_at) FROM users
-- MySQL-specific featuresSHOW TABLES-- Date functionsSELECT NOW(), DATE_ADD(NOW(), INTERVAL 1 DAY)-- String functionsSELECT CONCAT(first_name, ' ', last_name) FROM users-- Limit with offsetSELECT * FROM users LIMIT 10 OFFSET 20
-- SQL Server-specific featuresSELECT * FROM sys.tables-- TOP clauseSELECT TOP 10 * FROM users ORDER BY created_at DESC-- Date functionsSELECT GETDATE(), DATEADD(day, 1, GETDATE())-- String functionsSELECT CONCAT(first_name, ' ', last_name) FROM users
Browse Performance: Uses LIMIT and OFFSET for pagination. First page is instant, but jumping to page 1000 of a large table requires skipping many rows.
Query Performance:
Use WHERE clauses to filter data
Add LIMIT to large queries for faster results
Create indexes on frequently queried columns
Monitor execution times shown after each query
Export Performance: Exporting large tables (millions of rows) loads all data into memory before writing. For huge exports, consider: