SWAP_PARTITIONS_BETWEEN_TABLES
Swaps partitions between two tables.
Syntax
SWAP_PARTITIONS_BETWEEN_TABLES ( '[schema.]staging‑table', 'min‑range‑value', 'max‑range‑value', '[schema.]target‑table' )
Parameters
schema |
Specifies a schema. If multiple schemas are defined in the database, include the schema name. For example: myschema.thisDbObject |
staging‑table |
The staging table from which to swap partitions. |
min‑range‑value |
The minimum value of the partition to swap. |
max‑range‑value |
The maximum value of the partition to swap. |
target‑table |
The table to which the partitions are to be swapped. The target table cannot be the same as the staging table. |
Privileges
One of the following:
- DBADMIN role
- Owner of both tables
- USAGE privileges on both schemas, and TRUNCATE and INSERT privileges on both tables.
Table Attribute Requirements
The following attributes of both tables must be identical:
- Column definitions, including NULL/NOT NULL constraints
- Segmentation
- Partitioning expression
- 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, refer to Enforcing Primary Key and Foreign Key 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.
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 Swapping Partitions.