Commands Reference
Commands Reference
Section titled “Commands Reference”This comprehensive reference covers all available commands in the OstrichDB CLI, organized by category with syntax, examples, and use cases.
Command Categories
Section titled “Command Categories”Single-Token Commands
Section titled “Single-Token Commands”Commands that execute immediately without additional parameters.
Multi-Token Commands
Section titled “Multi-Token Commands”Commands that require additional tokens (location paths, parameters) to complete the operation.
System Commands
Section titled “System Commands”VERSION
Section titled “VERSION”Display the current version of OstrichDB.
Syntax:
VERSION
Example:
OstrichDB> VERSIONOstrichDB CLI v2.1.0
Use Cases:
- Check installed version
- Verify updates
- Troubleshooting compatibility
Display help information for commands.
Syntax:
# General helpHELP
# Specific command helpHELP <command>
Examples:
# General helpOstrichDB> HELPAvailable commands:NEW, FETCH, ERASE, RENAME, SET...
# Specific command helpOstrichDB> HELP NEWNEW - Create new collections, clusters, records, or usersSyntax: NEW <location> [OF_TYPE <type>] [WITH <value>]
Use Cases:
- Learn command syntax
- Get command examples
- Understand parameter options
Clear the terminal screen.
Syntax:
CLEAR
Example:
OstrichDB> CLEAR# Terminal screen is cleared
Use Cases:
- Clean up cluttered terminal
- Reset visual workspace
- Improve readability
End the OstrichDB session and close the CLI.
Syntax:
EXIT
Example:
OstrichDB> EXITGoodbye!# Returns to system terminal
Use Cases:
- Normal session termination
- Clean program exit
- Return to system shell
RESTART
Section titled “RESTART”Restart the OstrichDB program.
Syntax:
RESTART
Example:
OstrichDB> RESTARTRestarting OstrichDB...# Program restarts with fresh session
Use Cases:
- Apply configuration changes
- Clear temporary data
- Recover from errors
REBUILD
Section titled “REBUILD”Rebuild the DBMS and restart the program.
Syntax:
REBUILD
Example:
OstrichDB> REBUILDRebuilding OstrichDB...# System rebuilds and restarts
Use Cases:
- Apply system updates
- Fix compilation issues
- Reset system state
Data Exploration Commands
Section titled “Data Exploration Commands”Display the entire data structure in a tree format.
Syntax:
TREE
Example:
OstrichDB> TREE📁 Collections:├── users.ostrichdb│ ├── 📂 active│ │ ├── 📄 john_doe: STRING: "John Doe"│ │ └── 📄 john_email: STRING: "john@example.com"│ └── 📂 inactive│ └── 📄 old_user: STRING: "Former Employee"└── products.ostrichdb └── 📂 electronics ├── 📄 laptops: INTEGER: 25 └── 📄 phones: INTEGER: 50
Use Cases:
- Visualize data structure
- Understand hierarchy
- Debug data organization
- Overview of all data
HISTORY
Section titled “HISTORY”Show the current user’s command history.
Syntax:
HISTORY
Example:
OstrichDB> HISTORY1. NEW users.staff.alice OF_TYPE STRING WITH "Alice Johnson"2. FETCH users.staff.alice3. COUNT RECORDS IN users.staff4. TREE
Use Cases:
- Review recent commands
- Debug query sequences
- Repeat complex operations
- Track user activity
BENCHMARK
Section titled “BENCHMARK”Run performance tests on the DBMS.
Syntax:
# Basic benchmarkBENCHMARK
# Benchmark with parametersBENCHMARK <operation> <iterations>
Examples:
# Basic system benchmarkOstrichDB> BENCHMARKRunning standard benchmark...CREATE operations: 1000 ops/secFETCH operations: 2500 ops/secDELETE operations: 1200 ops/sec
# Specific operation benchmarkOstrichDB> BENCHMARK CREATE 1000Testing CREATE operations (1000 iterations)...Average: 0.8ms per operationTotal time: 800ms
Use Cases:
- Performance testing
- System optimization
- Capacity planning
- Troubleshooting slowness
Data Manipulation Commands
Section titled “Data Manipulation Commands”Create new collections, clusters, records, or users.
Syntax:
# Create structure onlyNEW <location>
# Create record with typeNEW <location> OF_TYPE <type>
# Create record with type and valueNEW <location> OF_TYPE <type> WITH <value>
# Create userNEW USER
Examples:
# Create collection and cluster automaticallyOstrichDB> NEW inventory.electronics.laptops
# Create typed recordOstrichDB> NEW users.staff.employee_count OF_TYPE INTEGER
# Create record with valueOstrichDB> NEW products.books.title OF_TYPE STRING WITH "Database Design"
# Create array recordOstrichDB> NEW teams.engineering.members OF_TYPE []STRING WITH "Alice,Bob,Carol"
# Create user accountOstrichDB> NEW USEREnter username: john_doeEnter password: ********User created successfully.
Use Cases:
- Initialize data structures
- Add new records
- Set up databases
- Create user accounts
Retrieve data from collections, clusters, or records.
Syntax:
FETCH <location>
Examples:
# Fetch specific recordOstrichDB> FETCH users.staff.aliceusers.staff.alice: STRING: "Alice Johnson"
# Fetch entire clusterOstrichDB> FETCH users.staffCluster: users.staff├── alice: STRING: "Alice Johnson"├── alice_email: STRING: "alice@company.com"└── alice_role: STRING: "Developer"
# Fetch collection overviewOstrichDB> FETCH usersCollection: users├── Cluster: staff (3 records)└── Cluster: contractors (1 record)
Use Cases:
- View record values
- Inspect cluster contents
- Review collection structure
- Data verification
Assign values to records or configurations.
Syntax:
# Set record valueSET <location> TO <value>
# Set configurationSET CONFIG <config_name> TO <value>
Examples:
# Update record valueOstrichDB> SET users.staff.alice_salary TO 80000
# Update configurationOstrichDB> SET CONFIG AUTO_SERVE TO true
# Set complex valuesOstrichDB> SET teams.engineering.tech_stack TO "React,Node.js,OstrichDB"
Use Cases:
- Update existing records
- Modify configurations
- Change system settings
- Data maintenance
Delete collections, clusters, or records.
Syntax:
ERASE <location>
Examples:
# Delete specific recordOstrichDB> ERASE users.staff.old_employee
# Delete entire clusterOstrichDB> ERASE users.inactive
# Delete collection (use with caution)OstrichDB> ERASE old_projectWarning: This will delete the entire collection. Confirm? (y/N): yCollection 'old_project' deleted.
Use Cases:
- Remove obsolete data
- Clean up test data
- Delete entire structures
- Data maintenance
RENAME
Section titled “RENAME”Rename existing collections, clusters, or records.
Syntax:
RENAME <old_location> TO <new_location>
Examples:
# Rename recordOstrichDB> RENAME users.staff.temp_employee TO users.staff.permanent_employee
# Rename clusterOstrichDB> RENAME projects.temp_project TO projects.website_redesign
# Rename collectionOstrichDB> RENAME old_inventory TO current_inventory
Use Cases:
- Fix naming mistakes
- Reorganize data structure
- Update naming conventions
- Refactor data organization
Remove all data from an object while maintaining the structure.
Syntax:
PURGE <location>
Examples:
# Purge cluster contentsOstrichDB> PURGE users.test_usersAll records in 'users.test_users' have been removed.
# Purge collection contentsOstrichDB> PURGE temp_dataAll clusters and records in 'temp_data' have been removed.
Use Cases:
- Clear test data
- Reset data structures
- Maintain structure while removing content
- Prepare for fresh data
Data Analysis Commands
Section titled “Data Analysis Commands”Count objects within a scope.
Syntax:
# Count all collectionsCOUNT COLLECTIONS
# Count clusters in collectionCOUNT CLUSTERS [IN <collection>]
# Count records in clusterCOUNT RECORDS [IN <location>]
Examples:
# Count all collectionsOstrichDB> COUNT COLLECTIONSTotal collections: 5
# Count clusters in specific collectionOstrichDB> COUNT CLUSTERS IN usersClusters in 'users': 3
# Count records in specific clusterOstrichDB> COUNT RECORDS IN users.staffRecords in 'users.staff': 12
# Count all recordsOstrichDB> COUNT RECORDSTotal records across all collections: 247
Use Cases:
- Monitor data growth
- Capacity planning
- Data analysis
- Structure validation
SIZE_OF
Section titled “SIZE_OF”Get the size in bytes of objects.
Syntax:
SIZE_OF <location>
Examples:
# Size of specific recordOstrichDB> SIZE_OF users.staff.alice_biographyusers.staff.alice_biography: 1,247 bytes
# Size of clusterOstrichDB> SIZE_OF users.staffusers.staff cluster: 15,432 bytes (12 records)
# Size of collectionOstrichDB> SIZE_OF usersusers collection: 23,891 bytes (3 clusters, 47 records)
Use Cases:
- Monitor storage usage
- Identify large data objects
- Optimize storage
- Capacity planning
TYPE_OF
Section titled “TYPE_OF”Get the data type of a record.
Syntax:
TYPE_OF <record_location>
Examples:
# Check record typeOstrichDB> TYPE_OF users.staff.employee_countusers.staff.employee_count: INTEGER
# Check array typeOstrichDB> TYPE_OF teams.engineering.membersteams.engineering.members: []STRING
# Check date typeOstrichDB> TYPE_OF projects.website.deadlineprojects.website.deadline: DATE
Use Cases:
- Verify data types
- Debug type mismatches
- Data validation
- Schema documentation
Search for records or clusters by name.
Syntax:
WHERE <search_term>
Examples:
# Find records containing "email"OstrichDB> WHERE emailFound matches:├── users.staff.alice_email├── users.staff.bob_email└── users.contractors.temp_email
# Find clusters containing "test"OstrichDB> WHERE testFound matches:├── users.test_users (cluster)└── projects.test_project (cluster)
Use Cases:
- Find specific records
- Locate data across collections
- Search by partial names
- Data discovery
Data Management Commands
Section titled “Data Management Commands”BACKUP
Section titled “BACKUP”Create backups of collections.
Syntax:
BACKUP <collection>
Examples:
# Backup specific collectionOstrichDB> BACKUP usersCreating backup of 'users' collection...Backup created: users_backup_2024-01-15_10-30-00.ostrichdb
# Backup critical dataOstrichDB> BACKUP financial_recordsCreating backup of 'financial_records' collection...Backup created: financial_records_backup_2024-01-15_10-31-45.ostrichdb
Use Cases:
- Data protection
- Before major changes
- Regular maintenance
- Disaster recovery
VALIDATE
Section titled “VALIDATE”Check collection integrity and validate for errors.
Syntax:
VALIDATE <collection>
Examples:
# Validate collectionOstrichDB> VALIDATE usersValidating 'users' collection...✓ File structure: OK✓ Data integrity: OK✓ Type consistency: OKCollection 'users' is valid.
# Validate with issuesOstrichDB> VALIDATE corrupted_dataValidating 'corrupted_data' collection...✗ File structure: CORRUPTED✗ Data integrity: 3 ERRORS FOUNDValidation failed. Run repair tools or restore from backup.
Use Cases:
- Check data integrity
- Troubleshoot issues
- Preventive maintenance
- Pre-operation validation
ISOLATE
Section titled “ISOLATE”Quarantine a collection to prevent changes.
Syntax:
ISOLATE <collection>
Examples:
# Isolate collectionOstrichDB> ISOLATE sensitive_dataCollection 'sensitive_data' has been isolated.No further modifications allowed.
# Attempt to modify isolated collectionOstrichDB> NEW sensitive_data.cluster.record OF_TYPE STRING WITH "test"Error: Collection 'sensitive_data' is isolated and cannot be modified.
Use Cases:
- Protect critical data
- Prevent accidental changes
- Compliance requirements
- Data preservation
CHANGE_TYPE
Section titled “CHANGE_TYPE”Change the data type of an existing record.
Syntax:
CHANGE_TYPE <record_location> TO <new_type>
Examples:
# Change string to integerOstrichDB> CHANGE_TYPE products.electronics.laptop_count TO INTEGERWarning: Current value "25" will be converted to INTEGER.Proceed? (y/N): yType changed: products.electronics.laptop_count is now INTEGER: 25
# Change to array typeOstrichDB> CHANGE_TYPE users.staff.skills TO []STRINGWarning: Current value will be converted to array format.Current: "Programming"New: ["Programming"]Proceed? (y/N): y
Use Cases:
- Fix type mistakes
- Schema evolution
- Data migration
- Type optimization
Security Commands
Section titled “Security Commands”Change collection access modes.
Syntax:
# Set to read-onlyLOCK <collection> -r
# Set to inaccessibleLOCK <collection>
Examples:
# Lock collection as read-onlyOstrichDB> LOCK financial_data -rCollection 'financial_data' locked in read-only mode.
# Lock collection completelyOstrichDB> LOCK archived_dataCollection 'archived_data' locked. No access allowed.
# Attempt to modify locked collectionOstrichDB> NEW financial_data.new_cluster.record OF_TYPE STRING WITH "test"Error: Collection 'financial_data' is locked in read-only mode.
Use Cases:
- Protect important data
- Prevent accidental modifications
- Enforce read-only access
- Data security
UNLOCK
Section titled “UNLOCK”Remove collection access restrictions.
Syntax:
UNLOCK <collection>
Examples:
# Unlock collectionOstrichDB> UNLOCK financial_dataCollection 'financial_data' unlocked. Full access restored.
# Verify unlockOstrichDB> NEW financial_data.test.record OF_TYPE STRING WITH "accessible"Record created successfully.
Use Cases:
- Restore full access
- Enable modifications
- Remove restrictions
- Maintenance operations
Encrypt a collection.
Syntax:
ENC <collection>
Examples:
# Encrypt collectionOstrichDB> ENC sensitive_dataEnter encryption password: ********Confirm password: ********Encrypting collection 'sensitive_data'...Collection encrypted successfully.
# Encrypted collection accessOstrichDB> FETCH sensitive_data.cluster.recordEnter decryption password: ********sensitive_data.cluster.record: STRING: "confidential information"
Use Cases:
- Protect sensitive data
- Compliance requirements
- Data security
- Confidential information
Decrypt an encrypted collection.
Syntax:
DEC <collection>
Examples:
# Decrypt collectionOstrichDB> DEC sensitive_dataEnter decryption password: ********Warning: This will permanently decrypt the collection.Proceed? (y/N): yDecrypting collection 'sensitive_data'...Collection decrypted successfully.
Use Cases:
- Remove encryption
- Permanent decryption
- Data migration
- Access simplification
Server Commands
Section titled “Server Commands”SERVE
/ SERVER
Section titled “SERVE / SERVER”Start the built-in HTTP server.
Syntax:
SERVE# orSERVER
Examples:
# Start serverOstrichDB> SERVEStarting OstrichDB HTTP Server...Server running on http://localhost:8080Press Ctrl+C to stop server.
# Server with custom port (if configured)OstrichDB> SERVEServer running on http://localhost:8089Ready to accept HTTP requests.
Use Cases:
- Enable HTTP API access
- Web application integration
- Remote database access
- Client application connectivity
Start the natural language processor (experimental).
Syntax:
AGENT
Examples:
# Start NLP agent (requires server running)OstrichDB> AGENTStarting Natural Language Agent...Agent ready. Type natural language queries.
Agent> Create a new user record for Alice with email alice@company.comProcessing: Creating user record...NEW users.staff.alice OF_TYPE STRING WITH "Alice"NEW users.staff.alice_email OF_TYPE STRING WITH "alice@company.com"Operations completed successfully.
Agent> exitReturning to standard CLI mode.
Use Cases:
- Natural language queries
- Simplified database interaction
- User-friendly interface
- Experimental features
User Management Commands
Section titled “User Management Commands”NEW USER
Section titled “NEW USER”Create a new user account.
Syntax:
NEW USER
Example:
OstrichDB> NEW USERCreating new user account...Enter username: john_doeEnter password: ********Confirm password: ********Enter email (optional): john@company.comUser 'john_doe' created successfully.
Use Cases:
- Multi-user setups
- Access control
- User management
- Authentication setup
LOGOUT
Section titled “LOGOUT”Log out the current user.
Syntax:
LOGOUT
Example:
OstrichDB> LOGOUTLogging out user 'john_doe'...User logged out successfully.Please log in to continue.
Login:
Use Cases:
- Switch users
- Security practices
- Session management
- Multi-user environments
Import/Export Commands
Section titled “Import/Export Commands”IMPORT
Section titled “IMPORT”Import data from CSV or JSON files.
Syntax:
IMPORT <file_path> TO <collection.cluster>
Examples:
# Import CSV fileOstrichDB> IMPORT /path/to/users.csv TO users.importedImporting CSV file...✓ Processed 250 records✓ Created users.imported clusterImport completed successfully.
# Import JSON fileOstrichDB> IMPORT /path/to/products.json TO inventory.productsImporting JSON file...✓ Processed 150 records✓ Created inventory.products clusterImport completed successfully.
Use Cases:
- Data migration
- Bulk data loading
- External data integration
- System initialization
Maintenance Commands
Section titled “Maintenance Commands”DESTROY
Section titled “DESTROY”Completely destroy the entire DBMS (use with extreme caution).
Syntax:
DESTROY
Example:
OstrichDB> DESTROY⚠️ WARNING: This will permanently delete ALL data, users, configs, and logs.Type 'DESTROY EVERYTHING' to confirm: DESTROY EVERYTHINGDestroying all OstrichDB data...✓ All collections deleted✓ User accounts deleted✓ Configuration files deleted✓ Logs cleared✓ System reset completeOstrichDB has been completely reset.
Use Cases:
- Complete system reset
- Start fresh installation
- Remove all traces
- Nuclear option
Query Chaining
Section titled “Query Chaining”Chain Operator (&&
)
Section titled “Chain Operator (&&)”Execute multiple commands in sequence.
Syntax:
<command1> && <command2> && <command3>
Examples:
# Create and verifyOstrichDB> NEW users.staff.alice OF_TYPE STRING WITH "Alice Johnson" && FETCH users.staff.aliceCreating record...users.staff.alice: STRING: "Alice Johnson"
# Complex operationsOstrichDB> NEW project.webapp.name OF_TYPE STRING WITH "Company Website" && NEW project.webapp.status OF_TYPE STRING WITH "Active" && COUNT RECORDS IN project.webapp && TREE
# Error handlingOstrichDB> NEW invalid.type OF_TYPE INVALID_TYPE WITH value && FETCH valid.recordError in first command: Invalid type 'INVALID_TYPE'Remaining commands skipped.
Use Cases:
- Batch operations
- Related tasks
- Efficient workflows
- Atomic operations
Best Practices
Section titled “Best Practices”Command Usage Tips
Section titled “Command Usage Tips”- Use
HELP
: Always check command syntax withHELP <command>
- Validate First: Use
VALIDATE
before major operations - Backup Before Changes: Use
BACKUP
before destructive operations - Check Types: Use
TYPE_OF
to verify data types - Monitor Size: Use
SIZE_OF
to track data growth
Error Prevention
Section titled “Error Prevention”- Test Queries: Try operations on test data first
- Use
TREE
: Visualize structure before complex operations - Chain Carefully: Understand that errors stop chain execution
- Validate Paths: Ensure location paths are correct
- Check Permissions: Verify access before operations
Performance Tips
Section titled “Performance Tips”- Use Specific Paths: Avoid broad
FETCH
operations - Regular Cleanup: Use
ERASE
to remove unused data - Monitor Performance: Use
BENCHMARK
regularly - Validate Regularly: Use
VALIDATE
to catch issues early - Optimize Queries: Chain related operations together
Next Steps
Section titled “Next Steps”Master these commands by:
- Understanding Data Types - Learn the type system
- Configuring OstrichDB - Customize your setup
- Practice: Use these commands with real data
- Experiment: Try different combinations and patterns
This command reference provides the foundation for all OstrichDB CLI operations. Bookmark this page and refer to it as you build your database management workflows.