Skip to content

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

connect

Purpose: Establish and save connection to SAP HANA database

Connection Quick Examples:

bash
# 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 -s

Aliases: 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:

bash
# 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 production

Aliases: exp, exportData


import

Purpose: Import data from file into table

Import Quick Examples:

bash
# 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 1000

Aliases: imp, importData


tableCopy

Purpose: Copy table structure or data between tables/schemas

Table Copy Quick Examples:

bash
# 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 --preview

Aliases: tc, copyTable


dataSync

Purpose: Synchronize data between source and target


Database Inspection

tables

Purpose: List tables in current or specified schema

Quick Examples:

bash
# 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:

bash
# 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 json

Aliases: 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:

bash
# 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:

bash
# 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 ADMIN

Aliases: cc, createHDI


Backup & Recovery

backup

Purpose: Create backups of tables, schemas, or databases

Quick Examples:

bash
# 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 false

Aliases: bkp, createBackup


restore

Purpose: Restore from backup

Quick Examples:

bash
# 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 --preview

Aliases: rst, restoreBackup


Performance Analysis

queryPlan

Purpose: Visualize SQL query execution plan

Quick Examples:

bash
# 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 json

alerts

Purpose: View database alerts and warnings

Quick Examples:

bash
# List all alerts
hana-cli alerts

# Show only high severity
hana-cli alerts -sev HIGH

# Limit to 20 results
hana-cli alerts -l 20

Aliases: alrt, alert


tableHotspots

Purpose: Identify frequently accessed tables


Mass Operations

massConvert

Purpose: Bulk convert tables to different formats

Quick Examples:

bash
# 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 cds

Aliases: mc, massConvertUI


massGrant

Purpose: Grant permissions on multiple objects

Quick Examples:

bash
# 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 --log

Aliases: mg, massPermission


massDelete

Purpose: Delete rows from multiple tables

Quick Examples:

bash
# 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 500

Aliases: md, massRemove


Cloud Integration

btp

Purpose: Set BTP target for commands

Quick Examples:

bash
# Set subaccount target
hana-cli btp --subaccount myaccount

# Set directory target
hana-cli btp --directory mydirectory

# Show current BTP context
hana-cli btpInfo

Aliases: 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

ParameterAliasTypeDefaultDescription
--admin-abooleanfalseUse admin credentials
--connstringConnection file override
--schema-sstring**CURRENT_SCHEMA**Target schema
--profile-pstringDatabase profile
--limit-lnumber200 (lists) / 1000 (data)Limit results
--output-ostringtblOutput format
--dryRun-dr, --previewbooleanfalsePreview without executing
--format-fstringcsvOutput/input format
--batchSize-b, --batchnumber1000Records per batch
--timeout-tonumber3600Operation timeout (sec)
--debug-dbooleanfalseDebug output
--quiet--disableVerbosebooleanfalseMinimal output

Getting More Information

For detailed documentation on any command, use:

bash
# 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-cli

Released under the Apache License 2.0