Vertica Analytics Platform Version 9.2.x Documentation
Copies partitions from one table to another. This lightweight partition copy increases performance by initially sharing the same storage between two tables. After the copy operation is complete, the tables are independent of each other. Users can perform operations on one table without impacting the other. These operations can increase the overall storage required for both tables.
Although they share storage space, Vertica considers the partitions as discrete objects for license capacity purposes. For example, copying a one TB partition would only consume one TB of space. Your Vertica license, however, considers them as separate objects consuming two TB of space.
COPY_PARTITIONS_TO_TABLE ( '[[database.]schema.]source‑table', 'min‑range‑value', 'max‑range‑value', '[[database.]schema.]target‑table' [, 'force‑split'] )
Specifies a schema, by default
If you specify a database, it must be the current database.
|source‑table||The source table of the partitions to copy.|
|The minimum and maximum value of partition keys to copy, where min‑range‑value must be ≤ max‑range‑value. To copy one partition, min‑range‑value and max‑range‑value must be equal.|
The target table of the partitions to copy. If the table does not exist, Vertica creates a table from the source table's definition, by calling
Optional Boolean argument, specifies whether to split ROS containers if the range of partition keys spans multiple containers or part of a single container:
- Ownership or USAGE privileges on the source table.
- CREATE privileges on the target table, if
Table Attribute Requirements
The following attributes of both tables must be identical:
- Column definitions, including NULL/NOT NULL constraints
- Partition clause
- Number of projections
- Projection sort order
- Primary and unique key constraints. However, the key constraints do not have to be identically enabled. For more information on constraints, see Constraints in the Administrator's Guide.
If the target table has primary or unique key constraints enabled and copying or moving the partitions will insert duplicate key values into the target table, Vertica rolls back the operation.
- Check constraints. For
COPY_PARTITIONS_TO_TABLE, Vertica enforces enabled check constraints on the target table only. For
SWAP_PARTITIONS_BETWEEN_TABLES, Vertica enforces enabled check constraints on both tables. If there is a violation of an enabled check constraint, Vertica rolls back the operation.
- Number and definitions of text indices.
The following restrictions apply to the source and target tables:
- If the source and target partitions are in different storage tiers, Vertica returns a warning but the operation proceeds. The partitions remain in their existing storage tier.
- The following tables cannot be used as sources or targets:
- Temporary tables
- Virtual tables
- System tables
- External tables
COPY_PARTITIONS_TO_TABLE returns an error if both of the following conditions are true of the source table:
- The table's partition expression includes a GROUP BY clause—for example, hierarchically partitioned tables.
- The table has projections that aggregate data—for example, live aggregate or Top-K projections.
If you call
COPY_PARTITIONS_TO_TABLE and the target table does not exist, the function creates the table automatically. In the following example, the target table
partn_backup.tradfes_200801 does not exist.
COPY_PARTITIONS_TO_TABLE creates the table and replicates the partition. Vertica also copies all the constraints associated with the source table except foreign key constraints.
=> SELECT COPY_PARTITIONS_TO_TABLE ( 'prod_trades', '200801', '200801', 'partn_backup.trades_200801'); COPY_PARTITIONS_TO_TABLE ------------------------------------------------- 1 distinct partition values copied at epoch 15. (1 row)
Was this topic helpful?