Compare results of two SQL queries to verify if they produce identical data. Checks structure, record count, and data content using MINUS/EXCEPT operations. Use when user needs to validate query equivalence, compare view logic, verify refactoring, or check data consistency.
All examples use the plain command name dbcli (no directory prefix).
Ensure dbcli is on PATH instead of hardcoding paths like .\.claude\skills\dbcli\dbcli.exe.
Compare results of two SQL queries to verify complete data consistency.
The comparison performs five checks:
dbcli compare "QUERY1" "QUERY2" [-c CONNECTION] [-t DBTYPE]
-t, --db-type: Database type (optional, default: "sqlite")DBCLI_CONNECTION: Database connection stringDBCLI_DBTYPE: Database type (alternative to -t)# Compare two views
dbcli compare "SELECT * FROM V_ORDERS_NEW" "SELECT * FROM V_ORDERS_OLD"
# Compare table with filtered query
dbcli compare "SELECT * FROM Orders WHERE Status='Active'" "SELECT * FROM Orders_Archive WHERE Status='Active'"
# Compare complex queries
dbcli compare "SELECT CustomerID, SUM(Amount) AS Total FROM Orders GROUP BY CustomerID" "SELECT CustomerID, SUM(Amount) AS Total FROM Orders_V2 GROUP BY CustomerID"
# SQLite (using environment variables)
export DBCLI_CONNECTION="Data Source=mydb.db"
export DBCLI_DBTYPE="sqlite"
dbcli compare "SELECT * FROM users WHERE active=1" "SELECT * FROM users_v2 WHERE active=1"
# SQL Server
export DBCLI_CONNECTION="Server=localhost;Database=testdb;Trusted_Connection=True"
dbcli -t sqlserver compare "SELECT * FROM Orders" "SELECT * FROM Orders_Backup"
# PostgreSQL
export DBCLI_CONNECTION="Host=localhost;Database=mydb;Username=postgres;Password=pass"
dbcli -t postgresql compare "SELECT * FROM sales WHERE year=2026" "SELECT * FROM sales_archive WHERE year=2026"
[1/3] Comparing record counts...
Query1: 14547 records
Query2: 14547 records
✓ Record counts match (14547 records)
[2/3] Checking differences (query1 - query2)...
Unique to query1: 0 records
[3/3] Checking differences (query2 - query1)...
Unique to query2: 0 records
✓ Query results are identical
[1/3] Comparing record counts...
Query1: 1520 records
Query2: 1518 records
✗ Record counts differ
[2/3] Checking differences (query1 - query2)...
Unique to query1: 5 records
[3/3] Checking differences (query2 - query1)...
Unique to query2: 3 records
✗ Query results differ (8 total differences)
0 - Query results are completely identical1 - Data or structure mismatch detected| Database | Operator | Notes |
|----------|----------|-------|
| DaMeng | MINUS | Native support |
| Oracle | MINUS | Native support |
| PostgreSQL | EXCEPT | Use EXCEPT instead of MINUS |
| Microsoft SQL Server | EXCEPT | Use EXCEPT instead of MINUS |
The dbcli compare command automatically detects the database type and uses the appropriate operator:
EXCEPTMINUS# Compare original and optimized query
dbcli compare "SELECT * FROM Orders WHERE Status='Active'" "SELECT * FROM Orders WHERE Status IN ('Active')"
# Compare view with underlying query
dbcli compare "SELECT * FROM V_SALES_SUMMARY" "SELECT CustomerID, SUM(Amount) AS Total FROM Sales GROUP BY CustomerID"
# Compare data across environments
dbcli compare "SELECT * FROM Users WHERE Active=1" "SELECT * FROM Users_Archive WHERE Active=1"
dbcli query "YOUR_SQL"-t flagSearch for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer