The following examples illustrate range fragmentation in its simple and hybrid forms.
The following example shows a simple range-fragmentation strategy:
CREATE TABLE Tab1 (Col1 INT...) FRAGMENT BY RANGE (Col1 MIN 100 MAX 200) IN db1, db2, db3, db4
In this example, the database server fragments the table according to the following allocations.
Storage Space | Holds Values | Storage Space | Holds Values | |
---|---|---|---|---|
db1 | 100 <= Col1 < 125 | db3 | 150 <= Col1 < 175 | |
db2 | 125 <= Col1 < 150 | db4 | 175 <= Col1 < 200 |
The previous table shows allocations that can also be made with an expression-based fragmentation scheme:
CREATE TABLE ... FRAGMENT BY EXPRESSION Col1 >= 100 AND Col1 < 125 IN db1 Col1 >= 125 AND Col1 < 150 IN db2 Col1 >= 150 AND Col1 < 175 IN db3 Col1 >= 175 AND Col1 < 200 IN db4
As the examples show, the range-fragmentation example requires much less coding to achieve the same results. The same is true for the hybrid-range fragmentation compared to hybrid-expression fragmentation methods.
The following example demonstrates the syntax for column-major-range allocation, a hybrid-range fragmentation strategy:
CREATE TABLE tab2 (col2 INT, colx char (5)) FRAGMENT BY HYBRID ( RANGE (col2 MIN 100 MAX 220)) RANGE (col2) IN dbsl1, dbsl2, dbsl3
This type of fragmentation creates a distribution across dbslices and provides a further subdivision within each dbslice (across the dbspaces in the dbslice) such that when a query specifies a value for col1 (for example, WHERE col1 = 127), the query uniquely identifies a dbspace. To take advantage of the additional subdivision, you must specify more than one dbslice.
The following example demonstrates the syntax for row-major-range allocation, a hybrid-range fragmentation strategy:
CREATE TABLE tab3 (col3 INT, colx char (5)) FRAGMENT BY HYBRID ( RANGE (col3) ) RANGE (col3 MIN 100 MAX 220) IN dbsl1, dbsl2, dbsl3
This fragmentation strategy is the counterpart to the column-major-range allocation. The advantages and restrictions are equivalent.
The following example demonstrates the syntax for an independent-range allocation, a hybrid-range fragmentation strategy:
CREATE TABLE tab4 (col4 INT, colx char (5), col5 INT) FRAGMENT BY HYBRID ( RANGE (col4 MIN 100 MAX 200) ) RANGE (col5 MIN 500 MAX 800) IN dbsl1, dbsl2, dbsl3
In this type of range fragmentation, the two columns are independent, and therefore the range allocations are independent. The range allocation for a dbspace on both columns is the conjunctive combination of the range allocation on each of the two independent columns.
This type of fragmentation does not provide subdivisions within either column. With this type of fragmentation, a query that specifies values for both columns (such as, WHERE col4 = 128 and col5 = 650) uniquely identifies the dbspace at the intersection of the two dbslices identified by the columns independently.
Use the PUT clause to specify the storage spaces and characteristics for each column that will contain smart large objects.
PUT Clause: .-,-----------------------------------------. | .-,-------. | V V | | |--PUT----+-column--IN--(----sbspace-+--)---------+-+-----------| | .-,---------------------------. | | V | | '-(----+-------------------------+-+--)-' +-EXTENT SIZE--kbytes-----+ | .-NO LOG-. | +-+--------+--------------+ | '-LOG----' | | .-HIGH INTEG-. | +-+------------+----------+ | .-NO KEEP ACCESS TIME-. | '-+---------------------+-' '-KEEP ACCESS TIME----'
Element | Description | Restrictions | Syntax |
---|---|---|---|
column | Column to store in sbspace | Must contain a BLOB, CLOB, user-defined, or complex data type | Identifier, p. Identifier |
kbytes | Number of kilobytes to allocate for the extent size | Must be an integer value | Literal Number,
p. Literal Number |
sbspace | Name of an area of storage | Must exist | Identifier, p. Identifier |
The column cannot be in the form column.field. That is, the smart large object that you are storing cannot be one field of a row type.
A smart large object is contained in a single sbspace. The SBSPACENAME configuration parameter specifies the system default in which smart large objects are created, unless you specify another area.
Specifying more than one sbspace distributes the smart large objects in a round-robin distribution scheme, so that the number of smart large objects in each space is approximately equal. The syscolattribs system catalog table contains one row for each sbspace that you specify in the PUT clause.
When you fragment smart large objects across different sbspaces, you can work with smaller sbspaces. If you limit the size of an sbspace, backup and archive operations can perform more quickly. For an example that uses the PUT clause, see Alternative to Full Logging.
Six storage options are available to store BLOB and CLOB data:
If a user-defined or complex data type contains more than one large object, the specified large-object storage options apply to all large objects in the type unless the storage options are overridden when the large object is created.