Expression Fragment Clause
In an expression-based distribution scheme, each fragment expression in a rule specifies a storage space. Each fragment expression in the rule isolates data and aids the database server in searching for rows.
This syntax fragment is part of the FRAGMENT BY clause.
Expression Fragment Clause .-,------------------------------------------------. V | |----+-----------------+--+-expr-------+--IN--dbspace-+----------+-> '-PARTITION--part-' '-(--expr--)-' '-INDEX OFF' >--+------------------------------------------------+-----------| '-,--+-----------------+-REMAINDER--IN--dbspace-'+----------+ '-PARTITION--part-' '-INDEX OFF-'
Element | Description | Restrictions | Syntax |
---|---|---|---|
part | Name of a fragment | Required if part is stored in the same dbspace as another fragment of this table. Must be unique among names of fragments of the same table. | Identifier |
dbspace | dbspace to store the table fragment | You can specify no more than 2,048 dbspaces. All dbspaces that store the fragments must have the same page size. | Identifier |
dbspace | |||
expr | An expression, based on column values, defining a fragment | Must return a Boolean value (true or false). Data values must be from a single row of the table. | Expression |
- Range rule
A range rule specifies fragment expressions that use a range to specify which rows are placed in a fragment, as the next example shows:
FRAGMENT BY EXPRESSION c1 < 100 IN dbsp1, c1 >= 100 AND c1 < 200 IN dbsp2, c1 >= 200 IN dbsp3;
- Arbitrary rule
An arbitrary rule specifies fragment expressions based on a predefined SQL expression that typically uses OR clauses to group data, as the following example shows:
FRAGMENT BY EXPRESSION zip_num = 95228 OR zip_num = 95443 IN dbsp2, zip_num = 91120 OR zip_num = 92310 IN dbsp4, REMAINDER IN dbsp5;
REMAINDER keyword
Use the REMAINDER keyword to specify the storage space in which to store valid values that fall outside the specified expression or expressions. If you do not specify a remainder, and a row is inserted or updated with values that do not correspond to any fragment definition, the database server returns an error.
CREATE TABLE T1 (c1 INT) FRAGMENT BY EXPRESSION PARTITION PART_1 (c1 = 10) IN dbs1, PARTITION PART_2 (c1 = 20) IN dbs1, PARTITION PART_3 (c1 = 30) IN dbs1, PARTITION PART_4 (c1 = 40) IN dbs2, PARTITION PART_5 (c1 = 50) IN dbs2, PARTITION PART_6 REMAINDER IN dbs2;
Here the first three fragments are stored in partitions of the dbs1 dbspace, and the other fragments, including the remainder, are stored in named fragments of the dbs2 dbspace. Explicit fragment names are required in this example, because each dbspace has multiple partitions.
Fragmentation in NLCASE INSENSITIVE databases
lname = 'Garcia'
where lname is a column of type NCHAR or NVARCHAR, rows
with the following values in that column would all be stored in the same fragment, because the
case-insensitive expression evaluates to TRUE for these (and similar) string
values:'Garcia' 'garcia' 'GARCIA' 'GarCia' 'gARCia'
For more information about NLSCASE INSENSITIVE databases, see CREATE DATABASE statement, Duplicate rows in NLSCASE INSENSITIVE databases, and NCHAR and NVARCHAR expressions in case-insensitive databases.