Skip to content

compareData ​

Command: compareData
Category: Data Tools
Status: Production Ready

Description ​

Compare data between two tables (optionally across schemas) and surface matches, differences, and rows that exist only on one side. You provide the key columns used to align rows, and you can optionally filter the comparison to specific columns.

Syntax ​

bash
hana-cli compareData [options]

Aliases ​

  • cmpdata
  • compardata
  • dataCompare

Command Diagram ​

Parameters ​

Positional Arguments ​

None.

Options ​

OptionAliasTypeDefaultDescription
--sourceTable--ststring-Source table name to compare.
--sourceSchema--ssstring**CURRENT_SCHEMA**Schema containing the source table.
--targetTable--ttstring-Target table name to compare.
--targetSchema--tsstring**CURRENT_SCHEMA**Schema containing the target table.
--keyColumns-kstring-Key columns for matching rows (comma-separated).
--columns-cstring-Specific columns to compare (comma-separated).
--showMatches--smbooleanfalseInclude matching rows in console output.
--output-ostring-Write a JSON report to a file path instead of console output.
--limit-lnumber1000Maximum rows to compare from each table.
--timeout--tonumber3600Operation timeout in seconds.
--profile-pstring-CDS profile for connections.

Connection Parameters ​

OptionAliasTypeDefaultDescription
--admin-abooleanfalseConnect via admin (default-env-admin.json).
--conn-string-Connection filename to override default-env.json.

Troubleshooting ​

OptionAliasTypeDefaultDescription
--disableVerbose--quietbooleanfalseDisable verbose output for scripting.
--debug-dbooleanfalseDebug hana-cli with detailed intermediate output.

Special Default Values ​

TokenResolves ToDescription
**CURRENT_SCHEMA**Current user's schemaUsed as default for --sourceSchema and --targetSchema.

Output ​

When --output is provided, the command writes a JSON report with a summary and three arrays: differences, sourceOnly, and targetOnly. When --output is not set, the command prints a summary to the console (and optionally matching rows when --showMatches is true).

Interactive Mode ​

In interactive mode, you are prompted for:

ParameterRequiredPromptedNotes
sourceTableYesAlwaysSource table to compare.
sourceSchemaNoAlwaysDefaults to current schema if omitted.
targetTableYesAlwaysTarget table to compare.
targetSchemaNoAlwaysDefaults to current schema if omitted.
keyColumnsYesAlwaysComma-separated key columns.
outputNoSkippedUse --output to write a file.
columnsNoSkippedUse --columns to limit comparison.
showMatchesNoSkippedUse --showMatches to include matches.
limitNoSkippedUse --limit to cap rows.
timeoutNoSkippedUse --timeout to cap runtime.
profileNoAlwaysOptional CDS profile.

Examples ​

bash
hana-cli compareData --sourceTable table1 --targetTable table2

See the Commands Reference for other commands in this category.

See Also ​