MAP PARTITION

MAP PARTITION — create an association between a table partition name and a storage group name

Syntax

MAP PARTITION partition_name STORE IN storage_group_name

Description

The MAP PARTITION command creates an association between a table partition name and a storage group name. This establishes a storage group name for subsequent partitions that do not otherwise establish a storage group name. The MAP PARTITION command has no effect on existing partitions. See Example 2 below. For information on create storage groups see Managing Storage Groups. To remove the mapping from a table partition name to a storage group, see UNMAP PARTITION.

Parameters

partition_name

The name you are giving to this table partition.

storage_group_name

The storage group to which this table partition will map.

Examples

<<<<<<< HEAD Example 1: Map a table partition called p1 to a previously created storage group sg1.
MAP PARTITION p1 STORE IN sg1;
Example 2: The MAP PARTITION command has no effect on existing partitions.
# Create a table T1 with partition P1 that stores values in storage group S1
CREATE TABLE t1 (f1 INTEGER) PARTITION BY RANGE(f1) PARTITION p1 
    VALUES LESS THAN(100) STORE IN s1;
 
# Map the partition name P1 to the storage group S2. This mapping doesn't affect 
# existing mapping for table T1.
MAP PARTITION p1 STORE IN s2;
 
# Data in table T2 partition P1 will be stored in storage group S2.
CREATE TABLE t2 (str1 STRING) PARTITION BY LIST(str1) PARTITION p1 VALUES IN('a','b');
======= Example 1: Map a table partition called p1 to a previously created storage group sg1.
MAP PARTITION P1 STORE IN SG1;
Example 2: The MAP PARTITION command has no effect on existing partitions.
CREATE TABLE Table1 (f1 int) PARTITION BY RANGE (f1) PARTITION P1 VALUES LESS THAN (10) STORE IN SG1;
MAP PARTITION P1 STORE IN SG2;
CREATE TABLE Table2 (f1 int) PARTITION BY RANGE (f1) PARTITION P1 VALUES LESS THAN (10);
UNMAP PARTITION P1;
MAP PARTITION P1 STORE IN SG3;
CREATE TABLE Table3 (f1 int) PARTITION BY RANGE (f1) PARTITION P1 VALUES LESS THAN (10);

SELECT tablename, partitionname, storagegroup FROM system.partitionids;

TABLENAME  PARTITIONNAME  STORAGEGROUP  
---------- -------------- ------------- 

Table1           P1           SG1      
Table2           P1           SG2      
Table3           P1           SG3
>>>>>>> ba916d9... DB-21340