UNMAP PARTITION

UNMAP PARTITION — remove the association between a table partition and a storage group

Syntax

UNMAP PARTITION partition_name [ IF EXISTS ]

Description

The UNMAP PARTITION command removes an association between a table partition name and a storage group. This has no effect on existing partitioned tables, whether its table partition mapping was created using the STORE IN clause or using the MAP command. UNMAP will succeed even if there are partitions using partition_name. See Example 2 below. The UNMAP PARTITION command has no effect on the storage group mapping to SMs. For information on how to create an association between a table partition name and a storage group, see MAP PARTITION. For information on creating or removing storage groups, see Managing Storage Groups.

Parameters

partition_name

The name of the table partition whose mapping you want to remove.

IF EXISTS

If the Table Partiton does not exist and you specify IF EXISTS, NuoDB does not generate an error. If not specified, and the Table Partitoin does not exist, an error is generated.

Examples

Example 1: Unmap a table partition tp1. If it doesn’t exist, don’t generate an error.
UNMAP PARTITION tp1 IF EXISTS;
Example 2: Unmapping a table partition name does not affect the partitioning behavior of existing tables.
# Create a table T1 with partition P1 that stores values by default in
# storage group S1.
CREATE TABLE t1 (f1 INTEGER) PARTITION BY RANGE(f1) PARTITION p1 VALUES LESS THAN(100) STORE IN s1;

# Create a mapping between the partition name P1 and the storage group S2.
MAP PARTITION p1 STORE IN s2;

# Create a table T2 with partition P1 that will by default store values
# in storage group S2 (because of the MAP command above).
CREATE TABLE t2 (str1 STRING) PARTITION BY LIST(str1) PARTITION p1 VALUES IN('a','b');

# Unmap the partition name P1 so that it is no longer associated with
# storage group S2. This does not change the partitioning behavior for
# tables T1 or T2.
UNMAP PARTITION p1 IF EXISTS;

# Create a table T3 with partition P1 and no STORE IN clause. This will cause an error because P1 is no longer mapped to a storage group.
CREATE TABLE t3 (f1 INTEGER)
    PARTITION BY RANGE(f1) PARTITION p1 VALUES LESS THAN(100);