SAP HANA CLI Command Structure Reference
This document provides visual diagrams and quick reference guides for the most commonly used hana-cli commands. Each command diagram shows the command structure, parameters, and typical usage patterns.
Table of Contents
- Connection Commands
- Data Operations
- Database Inspection
- HDI Container Management
- Backup & Recovery
- Performance Analysis
- Mass Operations
- Cloud Integration
Connection Commands
connect
Purpose: Establish and save connection to SAP HANA database
Connection Quick Examples:
# Interactive connection (prompts for details)
hana-cli connect
# Direct connection with credentials
hana-cli connect -n localhost:30013 -u DBUSER -p mypassword -s
# Using HDB Userstore key
hana-cli connect -U MYHDBKEY -sAliases: c, login
copy2DefaultEnv
Purpose: Convert .env file to default-env.json format
Data Operations
export
Purpose: Export data from tables/views to file
Export Quick Examples:
# Export table to CSV (default)
hana-cli export -t CUSTOMERS -s SALES
# Export to JSON with limit
hana-cli export -t PRODUCTS -f json -l 500 -o products.json
# Dry-run preview without saving
hana-cli export -t ORDERS -f csv --preview
# Export from specific profile
hana-cli export -t TABLE -p productionAliases: exp, exportData
import
Purpose: Import data from file into table
Import Quick Examples:
# Import CSV file with headers
hana-cli import -f users.csv -t USERS -h
# Import JSON and append to existing data
hana-cli import -f orders.json -t ORDERS -ap
# Import with dry-run preview
hana-cli import -f data.csv -t MYTABLE --preview
# Import specific number of records
hana-cli import -f large.csv -t TABLE -l 1000Aliases: imp, importData
tableCopy
Purpose: Copy table structure or data between tables/schemas
Table Copy Quick Examples:
# Copy structure only (no data)
hana-cli tableCopy --sourceTable ORDERS --targetTable ORDERS_ARCHIVE -so
# Copy data only to existing table
hana-cli tableCopy --sourceTable TABLE1 --targetTable TABLE2 -do
# Copy between schemas
hana-cli tableCopy -st PROD.CUSTOMERS -tt DEV.CUSTOMERS
# Copy with preview
hana-cli tableCopy --sourceTable ORDERS --targetTable ORDERS_BKP --previewAliases: tc, copyTable
dataSync
Purpose: Synchronize data between source and target
Database Inspection
tables
Purpose: List tables in current or specified schema
Quick Examples:
# List all tables in current schema
hana-cli tables
# List tables in specific schema
hana-cli tables -s PRODUCTION
# List with limit and JSON output
hana-cli tables -l 50 -o json
# Search for specific pattern
hana-cli tables CUST*Aliases: t, tbl, listTables
inspectTable
Purpose: Detailed inspection of table structure and metadata
Quick Examples:
# Inspect table (default output)
hana-cli inspectTable -s MYSCHEMA -t CUSTOMERS
# Get as CDS entity
hana-cli inspectTable MYSCHEMA CUSTOMERS -o cds
# Get as OData/EDMX
hana-cli inspectTable MYSCHEMA CUSTOMERS -o edmx
# Get as JSON schema
hana-cli inspectTable -t ORDERS -o jsonAliases: it, inspectTable, table
views
Purpose: List views in schema
Aliases: v, listViews
procedures
Purpose: List stored procedures in schema
Aliases: proc, sp, listProcedures
HDI Container Management
containers
Purpose: List HDI containers
Quick Examples:
# List all containers
hana-cli containers
# List specific container group
hana-cli containers -g MYGROUP
# Search with pattern
hana-cli containers -c "DEV*"Aliases: cont, listContainers
createContainer
Purpose: Create new HDI container
Quick Examples:
# Create container in default group
hana-cli createContainer MYCONTAINER
# Create with specific group
hana-cli createContainer MYCONTAINER -g MYGROUP
# Create with admin user
hana-cli createContainer HC01 -g APPS --adminUser ADMINAliases: cc, createHDI
Backup & Recovery
backup
Purpose: Create backups of tables, schemas, or databases
Quick Examples:
# Backup a table
hana-cli backup -t CUSTOMERS -s SALES
# Backup entire schema
hana-cli backup PRODUCTION --type schema
# Backup with compression
hana-cli backup -t TABLE -f csv -c true -d ./backups
# Backup without data
hana-cli backup MYSCHEMA --type schema --withData falseAliases: bkp, createBackup
restore
Purpose: Restore from backup
Quick Examples:
# Restore from backup file
hana-cli restore --backupFile customers.csv -t CUSTOMERS
# Restore with overwrite
hana-cli restore --backupFile ./backups/data.csv -t TABLE -ow
# Restore to different schema
hana-cli restore --backupFile backup.csv -t TABLE -s ALTERNATIVE_SCHEMA
# Dry-run restore
hana-cli restore --backupFile data.csv -t TABLE --previewAliases: rst, restoreBackup
Performance Analysis
queryPlan
Purpose: Visualize SQL query execution plan
Quick Examples:
# Analyze query execution plan
hana-cli queryPlan -q "SELECT * FROM CUSTOMERS WHERE ID = 1"
# Get JSON output
hana-cli queryPlan --sql "SELECT * FROM ORDERS" -o jsonalerts
Purpose: View database alerts and warnings
Quick Examples:
# List all alerts
hana-cli alerts
# Show only high severity
hana-cli alerts -sev HIGH
# Limit to 20 results
hana-cli alerts -l 20Aliases: alrt, alert
tableHotspots
Purpose: Identify frequently accessed tables
Mass Operations
massConvert
Purpose: Bulk convert tables to different formats
Quick Examples:
# Convert tables to CDS format (preview)
hana-cli massConvert -s MYSCHEMA -f cds --preview
# Convert to HDBTable format
hana-cli massConvert -s PRODUCTION -f hdbTable -d ./artifacts
# Convert specific tables by pattern
hana-cli massConvert -o "CUST*" -f cdsAliases: mc, massConvertUI
massGrant
Purpose: Grant permissions on multiple objects
Quick Examples:
# Grant SELECT to user (preview)
hana-cli massGrant -s MYSCHEMA -o CUST* -g DEVELOPER -p SELECT --preview
# Grant with grant option enabled
hana-cli massGrant -s SCHEMA -g ADMIN -p "SELECT,INSERT" --withGrantOption
# Apply grants with logging
hana-cli massGrant -o "TABLE*" -g USERS -p SELECT --logAliases: mg, massPermission
massDelete
Purpose: Delete rows from multiple tables
Quick Examples:
# Delete old records (preview)
hana-cli massDelete -o "ARCHIVE_*" -w "CREATE_DATE < '2023-01-01'" --preview
# Delete with batch processing
hana-cli massDelete -s STAGING -o TEMP* -b 500Aliases: md, massRemove
Cloud Integration
btp
Purpose: Set BTP target for commands
Quick Examples:
# Set subaccount target
hana-cli btp --subaccount myaccount
# Set directory target
hana-cli btp --directory mydirectory
# Show current BTP context
hana-cli btpInfoAliases: None
activateHDI
Purpose: Activate HDI service in tenant
Aliases: ahdi, ah
Command Pattern Reference
List Commands Pattern
All list commands follow this standard pattern:
Applies to: tables, views, procedures, functions, indexes, schemas, users, roles, sequences, synonyms, partitions, columnStats, spatialData, ftIndexes, graphWorkspaces, tableHotspots, tableGroups, calcViewAnalyzer
Data Operation Pattern
All data operations follow this standard pattern:
Applies to: export, import, dataSync, compareData, compareSchema, tableCopy, dataProfile, dataDiff, duplicateDetection
Parameter Inheritance Hierarchy
Quick Command Selection Guide
Parameter Quick Reference
Common Parameters Used Across Commands
| Parameter | Alias | Type | Default | Description |
|---|---|---|---|---|
--admin | -a | boolean | false | Use admin credentials |
--conn | — | string | — | Connection file override |
--schema | -s | string | **CURRENT_SCHEMA** | Target schema |
--profile | -p | string | — | Database profile |
--limit | -l | number | 200 (lists) / 1000 (data) | Limit results |
--output | -o | string | tbl | Output format |
--dryRun | -dr, --preview | boolean | false | Preview without executing |
--format | -f | string | csv | Output/input format |
--batchSize | -b, --batch | number | 1000 | Records per batch |
--timeout | -to | number | 3600 | Operation timeout (sec) |
--debug | -d | boolean | false | Debug output |
--quiet | --disableVerbose | boolean | false | Minimal output |
Getting More Information
For detailed documentation on any command, use:
# Show help for specific command
hana-cli [command] --help
hana-cli [command] -h
# Show overall help
hana-cli --help
hana-cli help
# See all available commands
hana-cliLinks to Related Documentation
- Main README - Overview and features
- Utils Documentation - Internal utilities
- Routes Documentation - HTTP API endpoints
- Swagger/OpenAPI - Interactive API docs
- Web Applications - Web UI documentation
