NoteOnly supported data types are included here. |
The following table identifies how SQL Anywhere or UltraLite remote data types are mapped to IBM DB2 UDB consolidated data types. For example, a column of type BIT on the remote database should be type SMALLINT on the consolidated database.
When creating a DB2 table, you need to pay attention to the DB2 page size. DB2 has a maximum row length (MRL) based on the page size: the MRL is 4005 when the page size is 4K, 8101 when 8K, 16293 when 16K and 32677 when 32K. The length of all columns in a table can't exceed the above limitation. If a table has a BLOB or CLOB column, you count row length using the LOB locator, not BLOB or CLOB data directly. For details, see the DB2 documentation.
SQL Anywhere or UltraLite data type |
IBM DB2 UDB data type | Notes |
---|---|---|
CHAR(n<MRL) |
VARCHAR(n) | |
CHAR(n>=MRL) |
CLOB(n) |
DB2 values can be longer than SQL Anywhere or UltraLite values, so make sure values are not too big when downloading. |
LONG NVARCHAR |
CLOB(n) |
There is no corresponding data type in DB2. If the DB2 character set is Unicode, SQL Anywhere LONG NVARCHAR can synchronize to DB2 CLOB. UltraLite doesn't have LONG NVARCHAR. |
LONG VARCHAR |
CLOB(n) | |
NCHAR(c) |
VARCHAR(n) or CLOB(n) |
There is no corresponding data type in DB2. If the DB2 character set is Unicode, NCHAR can synchronize to DB2 VARCHAR or CLOB. The size of SQL Anywhere NCHAR is characters and the size of DB2 VARCHAR is bytes. If you map to VARCHAR, the total bytes of NCHAR can not be bigger than MRL. Otherwise, NCHAR should map to CLOB. It is difficult to calculate the number of bytes in NCHAR(c), but it is approximately c=n/4. In general, if c is less than MRL/4, map to VARCHAR(n), but if c is greater than or equal to MRL/4, map to CLOB(n). |
NTEXT |
CLOB(n) |
There is no corresponding data type in DB2. If the DB2 character set is Unicode, NTEXT can synchronize to DB2 CLOB. |
NVARCHAR(c) |
VARCHAR(n) or CLOB(n) |
There is no corresponding data type in DB2. If the DB2 character set is Unicode, NVARCHAR can synchronize to DB2 VARCHAR or CLOB. The size of SQL Anywhere NVARCHAR is characters and the size of DB2 VARCHAR is bytes. If you map to VARCHAR, the total bytes of NVARCHAR can not be bigger than MRL. Otherwise, NVARCHAR should map to CLOB. It is difficult to calculate the number of bytes in NVARCHAR(c), but it is approximately c=n/4. In general, if c is less than MRL/4, map to VARCHAR(n), but if c is greater than or equal to MRL/4, map to CLOB(n). |
TEXT |
CLOB(n) | |
UNIQUEIDENTIFIERSTR |
CHAR(36) |
UNIQUEIDENTIFIERSTR is not recommended for DB2. Use UNIQUEIDENTIFIER instead. |
VARCHAR(n<MRL) |
VARCHAR(n) | |
VARCHAR(n>=MRL) |
CLOB(n) |
DB2 values can be longer than SQL Anywhere or UltraLite values, so make sure values are not too big when downloading. |
XML |
CLOB(n) | |
UNSIGNED BIGINT |
DECIMAL(20) |
For download, DB2 values must be non-negative. |
BIGINT |
BIGINT | |
BIT |
SMALLINT | |
DECIMAL(p<32,s) |
DECIMAL(p,s) |
The precision of SQL Anywhere DECIMAL is between 1 and 127. The maximum precision of DB2 DECIMAL is 31. |
DECIMAL(p>=32,s) |
Any data of SQL Anywhere DECIMAL precision greater than 31 cannot be synchronized to DB2. | |
DOUBLE |
DOUBLE |
DOUBLE is an imprecise numeric data type that is subject to rounding. When working with different types of computers, the underlying storage of DOUBLE is often different, resulting in different rounding. DOUBLE is a bad choice to use in a primary key because primary keys are looking for equality. This is especially true in a synchronization environment because the consolidated database often runs on different hardware from the remote database. |
FLOAT(1-24) |
REAL |
FLOAT can cause problems if the consolidated and remote databases don't allow the exact same (imprecise) values. We do not test all possible values, so care must be taken. To avoid problems, do not use these types as part of a primary key. |
FLOAT(25-53) |
DOUBLE |
FLOAT can cause problems if the consolidated and remote databases don't allow the exact same (imprecise) values. We do not test all possible values, so care must be taken. To avoid problems, do not use these types as part of a primary key. |
UNSIGNED INTEGER |
DECIMAL(11) |
For download, DB2 values must be non-negative. |
INTEGER |
INTEGER | |
NUMERIC(p<32,s) |
NUMERIC(p,s) | |
NUMERIC(p>=32,s) | There is no corresponding data type in DB2. | |
REAL |
REAL |
REAL can cause problems if the consolidated and remote databases don't allow the exact same (imprecise) values. We do not test all possible values, so care must be taken. To avoid problems, do not use these types as part of a primary key. |
UNSIGNED SMALLINT |
DECIMAL(5) |
For download, DB2 values must be non-negative. |
SMALLINT |
SMALLINT | |
UNSIGNED TINYINT |
SMALLINT |
For download, DB2 values must be non-negative. |
TINYINT |
SMALLINT |
For download, DB2 values must be non-negative. |
MONEY |
DECIMAL(19,4) | |
SMALLMONEY |
DECIMAL(10,4) | |
LONG VARBIT |
CLOB(n) | |
VARBIT(n<MRL) |
VARCHAR(n) | |
VARBIT(n>=MRL) |
CLOB(n) | |
DATE |
DATE |
For SQL Anywhere and UltraLite, the time value must in the format 00:00:00. |
DATETIME |
TIMESTAMP | |
SMALLDATETIME |
TIMESTAMP | |
TIME |
TIMESTAMP or TIME |
SQL Anywhere and UltraLite TIME values with fractional seconds require DB2 TIMESTAMP. SQL Anywhere and UltraLite time values with fractional seconds that are always zero can use DB2 TIME. |
TIMESTAMP |
TIMESTAMP | |
BINARY(n<MRL) |
VARCHAR(n) FOR BIT DATA | |
BINARY(n>=MRL) |
BLOB(n) | |
IMAGE |
BLOB(n) | |
LONG BINARY |
BLOB(n) | |
UNIQUEIDENTIFIER |
CHAR(36) | |
VARBINARY(n<MRL) |
VARCHAR(n) FOR BIT DATA | |
VARBINARY(n>=MRL) |
BLOB(n) |
The following table identifies how IBM DB2 UDB consolidated data types are mapped to SQL Anywhere or UltraLite remote data types. For example, a column of type INT on the consolidated database should be type INTEGER on the remote database.
When creating a DB2 table, you need to pay attention to the DB2 page size. DB2 has a maximum row length based on the page size: the MRL is 4005 when the page size is 4K, 8101 when 8K, 16293 when 16K and 32677 when 32K. The length of all columns in a table can't exceed the above limitation. If a table has a BLOB or CLOB column, you count row length using the LOB locator, not BLOB or CLOB data directly. For details, see the DB2 documentation.
IBM DB2 UDB data type | SQL Anywhere or UltraLite data type | Notes |
---|---|---|
SMALLINT |
SMALLINT | |
INT |
INTEGER | |
BIGINT |
BIGINT | |
REAL |
REAL |
REAL can cause problems if the consolidated and remote databases don't allow the exact same (imprecise) values. We do not test all possible values, so care must be taken. To avoid problems, do not use these types as part of a primary key. |
DOUBLE |
DOUBLE |
DOUBLE is an imprecise numeric data type that is subject to rounding. When working with different types of computers, the underlying storage of DOUBLE is often different, resulting in different rounding. DOUBLE is a bad choice to use in a primary key because primary keys are looking for equality. This is especially true in a synchronization environment because the consolidated database often runs on different hardware from the remote database. |
FLOAT |
DOUBLE |
FLOAT can cause problems if the consolidated and remote databases don't allow the exact same (imprecise) values. We do not test all possible values, so care must be taken. To avoid problems, do not use these types as part of a primary key. |
DECIMAL(p,s) |
DECIMAL(p,s) | |
NUMERIC(p,s) |
NUMERIC(p,s) | |
CHAR(n) |
VARCHAR(n) |
There is no equivalent to DB2 CHAR in SQL Anywhere. You should not use CHAR in a consolidated database column that is synchronized. If you must synchronize DB2 CHAR columns, run MobiLink server with the -b option. |
VARCHAR(n) |
VARCHAR(n) | |
LONG VARCHAR |
VARCHAR(32700) | |
CLOB(n) |
LONG VARCHAR | |
CHAR(n) FOR BIT DATA |
BINARY(n) | |
VARCHAR(n) FOR BIT DATA |
VARBINARY(n) | |
LONG VARCHAR FOR BIT DATA |
VARBINARY(32700) | |
GRAPHIC(n) |
VARCHAR(2n) |
DB2 GRAPHIC will do blank-padding, but SQL Anywhere CHAR will not. We recommend that you do not use this data type. The data type GRAPHIC is only used for double-byte characters. SQL Anywhere does not have a corresponding data type. When the DB2 character set is Unicode, GRAPHIC is equivalent to CHAR. |
VARGRAPHIC(n) |
VARCHAR(2n) |
The data type VARGRAPHIC is only used for double-byte characters. SQL Anywhere does not have a corresponding data type. When the DB2 character set is Unicode, VARGRAPHIC is equivalent to VARCHAR. |
LONG VARGRAPHIC(n) |
VARCHAR(32700) |
The data type LONG VARGRAPHIC is only used for double-byte characters. SQL Anywhere does not have a corresponding data type. When the DB2 character set is Unicode, LONG VARGRAPHIC is equivalent LONG VARCHAR. |
DBCLOB(n) |
LONG VARCHAR |
The data type DBCLOB(n) is only used for double-byte characters. SQL Anywhere does not have a corresponding data type. When the DB2 character set is Unicode, DBCLOB(n) is equivalent to CLOB. |
BLOB |
LONG BINARY | |
DATE |
DATE |
For SQL Anywhere and UltraLite, the time value must in the format 00:00:00. |
TIME |
TIME |
The fractional seconds values from SQL Anywhere TIME values will be truncated on download. To avoid problems, do not use fractional seconds. |
TIMESTAMP |
TIMESTAMP |