CLI Reference¶
The Rust CLI is implemented in crates/decentdb-cli and shipped as the decentdb binary.
Most commands take --db=<path>. Use :memory: for an ephemeral in-memory database.
Commands¶
version¶
exec¶
Execute one or more SQL statements.
Supported options: - --params=<type:value> repeatable positional parameters (int:1, float:1.5, bool:true, text:hello, blob:deadbeef, timestamp:1700000000, null) - --format=<json|csv|table> output format, default json - --checkpoint checkpoint after execution, or checkpoint-and-exit if --sql is omitted - --openClose open and close the database without executing SQL - --dbInfo print storage info and exit - --noRows discard result rows and report only the affected row count - --cachePages=<n> cache size in 4KB pages - --cacheMb=<n> cache size in megabytes, overrides --cachePages
repl¶
Interactive SQL shell with: - multi-line input - persistent history in ~/.decentdb_history - transaction-aware prompt state
Special commands: - .help - .quit - .exit
import¶
Import CSV data into a table using the bulk-load path.
Current Rust CLI scope: CSV import only.
export¶
Export a table as CSV or JSON.
bulk-load¶
Bulk load CSV data with explicit bulk-load options.
Supported options: - --batchSize=<n> - --syncInterval=<n> - --disableIndexes - --noCheckpoint
checkpoint¶
save-as¶
Write a checkpointed snapshot into a new on-disk database file.
migrate¶
Check a database file and assist in migrating unsupported legacy formats. Currently, this command detects the source version and provides a helpful message explaining the manual logical dump/restore path if the engine cannot natively upgrade it.
info¶
Show storage-level information.
describe¶
Describe one table.
list-tables¶
list-indexes¶
list-views¶
dump¶
Dump the current catalog and table contents as deterministic SQL.
dump-header¶
Decode and print the fixed page-1 header.
rebuild-index¶
rebuild-indexes¶
completion¶
Emit a small static shell completion script.
stats¶
Show page and cache sizing information.
vacuum¶
Checkpoint and rewrite the database into a new output file.
verify-header¶
Open the database, validate the fixed header, and print the decoded fields.
verify-index¶
Rebuild a named index logically and compare entry counts against the current runtime copy.
doctor (new in v2.3)¶
Run a diagnostic health check against a database file. Doctor is read-only by default and does not mutate the database unless --fix is present.
Supported options:
--format=<json|markdown>output format, defaultmarkdown--checks=<all|header,storage,wal,fragmentation,schema,statistics,indexes,compatibility>limit checks to selected categories, defaultall--verify-index=<name>repeatable, run expensive logical verification for named indexes--verify-indexesrun expensive logical verification for all indexes up to--max-index-verify--max-index-verify=<n>safety cap for--verify-indexes, default32--fail-on=<info|warning|error>minimum severity that makes the process exit non-zero, defaulterror--include-recommendations[=true|false]include safe recommendation text and commands, defaulttrue--path-mode=<absolute|basename|redacted>controls path rendering in output, defaultabsolute--fixapply v1 auto-fixable actions after diagnosis, then re-run diagnosis
Exit codes:
| Code | Meaning |
|---|---|
| 0 | No findings, or findings below --fail-on threshold |
| 1 | Unexpected error (invalid args, engine failure) |
| 2 | Findings at or above --fail-on threshold |
Basic Markdown example:
Sample output:
# DecentDB Doctor Report
## Status
Overall status: WARNING
## Database
| Field | Value |
|---|---|
| Path | my.ddb |
| Format version | 10 |
| Page size | 4096 |
...
## Summary
| Severity | Count |
|---|---:|
| Error | 0 |
| Warning | 1 |
| Info | 2 |
## Findings
### WARNING wal.large_file -- WAL file is large relative to the database
...
JSON / CI example:
The JSON output includes schema_version, mode, status, database, summary, pre_fix_findings, findings, fixes, and collected objects. This format is the stable integration surface for CI pipelines and tooling.
Index verification example:
Expensive verification is always opt-in. Default runs do not verify any indexes.
Fix mode example:
When --fix is present, doctor:
- Collects diagnostic findings.
- Plans eligible fixes from the v1 fix action catalog.
- Applies fixes in deterministic order.
- Re-collects facts and re-runs checks.
- Reports
mode="fix",pre_fix_findings,findings, andfixes.
v1 auto-fixable findings:
| Fix action | Trigger finding | Precondition |
|---|---|---|
fix.checkpoint | wal.large_file | No active readers |
fix.rebuild_stale_index | schema.index_not_fresh | Index still exists |
fix.rebuild_invalid_index | index.verify_failed | Verification was requested in the same run |
v1 non-auto-fixable findings (recommendations only):
header.unreadabledatabase.open_failedcompatibility.format_version_unknownwal.many_versionswal.long_readers_presentwal.reader_warnings_recordedwal.shared_enabledfragmentation.highfragmentation.moderateschema.no_user_tablesschema.many_indexes_on_tableindex.verify_errorindex.verify_skipped_limit
Fragmentation is deliberately not auto-fixed because the safe vacuum workflow writes a separate output database. Use decentdb vacuum for that case.
Recommendation safety:
- Doctor suggests safe actions by default (e.g., checkpoint commands).
- When
--fixis present, only the explicit v1 fix action catalog is executed. - Doctor never overwrites or replaces the source database.
- No destructive operations (source-overwriting vacuum, unsafe compaction) are performed.
Output Formats¶
json renders machine-readable tables or command results.
csv renders comma-separated rows.
table renders an aligned plain-text table with headers.