schemaClone β
Command:
schemaClone
Category: Schema Tools
Status: Production Ready
Description β
Clones schema tables (and optionally table data) from a source schema to a target schema. This is useful for creating development environments, backups, or sandbox schemas for testing.
Syntax β
bash
hana-cli schemaClone [options]Aliases β
schemaclonecloneSchemacopyschema
Command Diagram β
Parameters β
Positional Arguments β
This command has no positional arguments.
Options β
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--sourceSchema | -ss | string | **CURRENT_SCHEMA** | Source schema to clone from. |
--targetSchema | -ts | string | **CURRENT_SCHEMA** | Target schema to clone to. |
--includeData | -id | boolean | false | Copy table data in addition to structure. |
--includeGrants | -ig | boolean | false | Include grant discovery/reporting workflow. |
--parallel | -par | number | 1 | Accepted parallelism parameter for clone workflows. |
--excludeTables | -et | string | - | Comma-separated tables to exclude. |
--dryRun | -dr, --preview | boolean | false | Accepted preview flag for dry-run workflows. |
--timeout | --to | number | 7200 | Operation timeout in seconds. |
--profile | -p | string | - | Connection profile to use. |
Connection Parameters β
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--admin | -a | boolean | false | Use admin connection settings. |
--conn | - | string | Config-dependent | Override connection file. |
Troubleshooting β
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--disableVerbose | --quiet | boolean | false | Reduce verbose output. |
--debug | -d | boolean | false | Enable debug output. |
Cloning Process β
The command performs these steps:
- Schema Verification: Checks if source schema exists
- Target Creation: Creates target schema if it doesn't exist
- Table Discovery: Lists all tables in source schema
- Table Filtering: Applies exclude filter if specified
- Structure Cloning: Creates table structures using
CREATE TABLE ... LIKE - Data Copying: Copies data if
--includeDataspecified - View Cloning: Identifies views (manual recreation may be needed)
- Grant Processing: Reads grant metadata when
--includeGrantsis specified - Summary Report: Displays cloning statistics
Object Types Cloned β
Automatically Cloned β
- β Tables (structure)
- β
Table data (if
--includeData) - β Column definitions
- β Primary keys
- β Unique constraints
Requires Manual Handling β
- β οΈ Views (DDL display only)
- β οΈ Stored procedures
- β οΈ Functions
- β οΈ Sequences
- β οΈ Synonyms
- β οΈ Triggers
- β οΈ Foreign key constraints
- β οΈ Privilege replay (grant application)
Output Format β
text
Starting schema clone from PRODUCTION to DEVELOPMENT
Creating target schema DEVELOPMENT
Found 25 table(s) to clone
Cloning table: CUSTOMERS
Copied 15,432 row(s) to table CUSTOMERS
Cloning table: ORDERS
Copied 89,765 row(s) to table ORDERS
Cloning table: PRODUCTS
Copied 3,421 row(s) to table PRODUCTS
...
Found 8 view(s) to clone
Cloning view: CUSTOMER_SUMMARY
View CUSTOMER_SUMMARY skipped (requires manual DDL conversion)
...
Schema clone complete. Source: PRODUCTION, Target: DEVELOPMENT, Tables: 25, Rows: 234,567
ββββββββββββββββββ¬βββββββββββββββββ¬ββββββββββββββββ¬ββββββββββββββ¬βββββββββββββββ¬βββββββββββββββββββ
β SOURCE_SCHEMA β TARGET_SCHEMA β TABLES_CLONED β ROWS_COPIED β DATA_INCLUDEDβ GRANTS_INCLUDED β
ββββββββββββββββββΌβββββββββββββββββΌββββββββββββββββΌββββββββββββββΌβββββββββββββββΌβββββββββββββββββββ€
β PRODUCTION β DEVELOPMENT β 25 β 234567 β YES β NO β
ββββββββββββββββββ΄βββββββββββββββββ΄ββββββββββββββββ΄ββββββββββββββ΄βββββββββββββββ΄βββββββββββββββββββExamples β
1. Basic Schema Clone (Structure Only) β
Clone schema structure without data:
bash
hana-cli schemaClone -ss PRODUCTION -ts DEVELOPMENT2. Clone Schema with Data β
Clone schema including all table data:
bash
hana-cli schemaClone \
-ss PRODUCTION \
-ts DEV_SANDBOX \
-id3. Clone with Grants β
Clone schema structure and security grants:
bash
hana-cli schemaClone \
-ss MAIN_SCHEMA \
-ts BACKUP_SCHEMA \
-ig4. Full Clone with Data and Grants β
Complete schema clone including everything:
bash
hana-cli schemaClone \
-ss PROD_SCHEMA \
-ts TEST_SCHEMA \
-id \
-ig5. Exclude Specific Tables β
Clone schema but exclude temporary or log tables:
bash
hana-cli schemaClone \
-ss SALES_SCHEMA \
-ts SALES_ARCHIVE \
-id \
-et TEMP_LOGS,DEBUG_TABLE,STAGING_DATA6. Parallel Cloning for Performance β
Use parallel operations for faster cloning:
bash
hana-cli schemaClone \
-ss LARGE_SCHEMA \
-ts LARGE_SCHEMA_COPY \
-id \
-par 47. Extended Timeout for Large Schemas β
Increase timeout for very large schemas:
bash
hana-cli schemaClone \
-ss BIG_DATA_SCHEMA \
-ts BIG_DATA_BACKUP \
-id \
--timeout 14400Use Cases β
- Development Environments: Create dev/test copies of production schemas
- Schema Backup: Quick schema-level backups before major changes
- Sandbox Creation: Create isolated environments for testing
- Data Migration: Move schema structure to different systems
- Schema Versioning: Create timestamped schema snapshots
- Performance Testing: Clone production structure for load testing
Performance Considerations β
- Without Data (
-idnot set): Very fast, structure-only copy - With Data (
-idset): Time depends on data volume - Parallel Operations (
-par): Can significantly speed up large schemas - Network Speed: Affects data copy performance
- Table Size: Large tables take proportionally longer
Prerequisites β
- CREATE SCHEMA privilege (if target doesn't exist)
- SELECT privilege on source schema
- CREATE TABLE privilege on target schema
- INSERT privilege on target schema (if copying data)
- Sufficient disk space for cloned data
Notes β
- Target schema will be created if it doesn't exist
- If target schema exists, tables are added (existing tables not dropped)
- Views require manual DDL conversion due to schema name dependencies
- Foreign keys may need manual recreation after cloning
- Sequences need to be adjusted for current values
- Consider excluding large log or temporary tables
- Use appropriate timeout for schema size
- Indexes are created automatically with table structure
- Partitioning is preserved in table structure
Troubleshooting Scenarios β
Error: Source schema not found β
- Verify source schema name spelling and case
- Check database connection
Error: Permission denied β
- Ensure you have appropriate privileges
- May need SCHEMA OWNER or DBA role
Timeout errors β
- Increase timeout parameter
- Reduce parallel operations
- Exclude large tables
Out of disk space β
- Check available space before cloning large schemas
- Consider cloning without data first
- Exclude unnecessary tables
Related Commands β
schemas- List available schemas.tables- Inspect tables in schemas.export- Export schema/table data.
See the Commands Reference for other commands in this category.