MOVE_PARTITIONS_TO_TABLE
Moves partitions from one table to another.
This is a meta-function. You must call meta-functions in a top-level SELECT statement.
Behavior type
VolatileSyntax
MOVE_PARTITIONS_TO_TABLE (
'[[database.]schema.]source-table',
'min-range-value',
'max-range-value',
'[[database.]schema.]target-table'
[, force-split]
)
Parameters
[
database
.]
schema
Database and schema. The default schema is
public
. If you specify a database, it must be the current database.source-table
- The source table of the partitions to move.
min-range-value
max-range-value
- The minimum and maximum value of partition keys to move, where
min-range-value
must be ≤max-range-value
. To move one partition,min-range-value
andmax-range-value
must be equal. target-table
- The target table of the partitions to move. If the table does not exist, Vertica creates a table from the source table's definition, by calling
CREATE TABLE
withLIKE
andINCLUDING PROJECTIONS
clause. The new table inherits ownership from the source table. For details, see Replicating a table. force-split
Optional Boolean argument, specifies whether to split ROS containers if the range of partition keys spans multiple containers or part of a single container:
-
true
: Split ROS containers as needed. -
false
(default): Return with an error if ROS containers must be split to implement this operation.
-
Privileges
Non-superuser, one of the following:
-
Owner of source and target tables
-
SELECT, TRUNCATE on the source table, INSERT on the target table
If the target table does not exist, you must also have CREATE privileges on the target schema to enable table creation.
Table attribute requirements
The following attributes of both tables must be identical:
-
Column definitions, including NULL/NOT NULL constraints
-
Segmentation
-
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.
Note
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
MOVE_PARTITIONS_TO_TABLE
andCOPY_PARTITIONS_TO_TABLE
, Vertica enforces enabled check constraints on the target table only. ForSWAP_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.
Additionally, If access policies exist on the source table, the following must be true:
-
Access policies on both tables must be identical.
-
One of the following must be true:
-
The executing user owns the source table.
-
AccessPolicyManagementSuperuserOnly
is set to true. See Managing access policies for details.
-
Table restrictions
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
-
Examples
See Archiving partitions.