Chapter Contents |
Previous |
Next |
SAS/ACCESS Software for Relational Databases: Reference |
String Data |
The DB2 string data types are listed here.
Numeric Data |
The DB2 numeric data types are listed here.
If s is omitted, 0 is assigned and p may also be omitted. Omitting both s and p results in the default DEC(5,0). The maximum range of p is 1 -1031 to 1031 -1.
Even though the DB2 numeric columns have these distinct data types, the DB2 engine accesses, inserts, and loads all numerics as FLOATs.
Dates, Times, and Timestamps |
DB2 NULLs and DB2 Default Values |
Columns can be defined so that they do not allow NULL data. NOT NULL would indicate, for example, that DB2 does not allow a row to be added to the TESTID.CUSTOMERS table unless there's a value for CUSTOMER.
Columns can also be defined as NOT NULL WITH DEFAULT. The following table lists the default values assigned by DB2 to columns that are defined as NOT NULL WITH DEFAULT. An example of such a column is STATE in TESTID.CUSTOMERS. If a column is omitted from a view descriptor, default values are assigned to the column. However, if a column is specified in a view descriptor and it has no values, no default values are assigned.
DB2 Column Type | DB2 Default* |
---|---|
CHAR(n) | GRAPHIC(n) | blanks, unless the NULLCHARVAL= option is specified |
VARCHAR | LONG VARCHAR | VARGRAPHIC | LONG VARGRAPHIC | empty string |
SMALLINT | INT | FLOAT | DECIMAL | REAL | 0 |
DATE | current date, derived from the system clock |
TIME | current time, derived from the system clock |
TIMESTAMP | current timestamp, derived from the system clock |
*The default values that are listed in this table pertain to values that are assigned by DB2. |
Knowing whether a DB2 column allows NULL values or whether DB2 supplies a default value can assist you in writing selection criteria and in entering values to update a table. Unless a column is defined as NOT NULL or NOT NULL WITH DEFAULT, the column allows NULL values.
LIBNAME Statement Data Conversions |
DB2 Column Type | Default SAS Format |
---|---|
CHAR(n) | $n. (n<=254) |
VARCHAR(n) | $n. $255. (n>255) |
LONG VARCHAR | $n. |
GRAPHIC(n), VARGRAPHIC(n), LONG VARGRAPHIC | $n.( n<=127) $127. (n>127) |
INTEGER | m.n |
SMALLINT | m.n |
DECIMAL(m,n) | m.n |
FLOAT | none |
NUMERIC(m,n) | m.n |
DATE | DATE9. |
TIME | TIME8. |
DATETIME | DATETIME30.6 |
The following table shows the default DB2 data types that are assigned to SAS variable formats during output operations.
SAS Variable Format | DB2 Data Type |
---|---|
$w., $CHARw., $VARYINGw., $HEXw. | CHARACTER |
any date format | DATE |
any time format | TIME |
any datetime format | TIMESTAMP |
all other numeric formats | FLOAT |
ACCESS Procedure Data Conversions |
DB2 Column Type | Default SAS Format |
---|---|
CHAR(n) | $n. (n<=199) |
VARCHAR(n) | $n. $200. (n>200) |
LONG VARCHAR | $n. |
GRAPHIC(n), VARGRAPHIC(n), LONG VARGRAPHIC | $n.( n<=127) $127. (n>127) |
INTEGER | 11.0 |
SMALLINT | 6.0 |
DECIMAL(m,n) | m+2.s for example, DEC(6,4) = 8.4 |
REAL | E12.6 |
DOUBLE PRECISION | E12.6 |
FLOAT(n) | E12.6 |
FLOAT | E12.6 |
NUMERIC(m,n) | m.n |
DATE | DATE7. |
TIME | TIME8. |
DATETIME | DATETIME30.6 |
Note: You can use the YEARCUTOFF= option to
make your DATE7.
dates comply with Year 2000 standards. For more information about this SAS
system option, see SAS Language Reference: Dictionary.
DBLOAD Procedure Data Conversions |
SAS Variable Format | DB2 Data Type |
---|---|
$w., $CHARw., $VARYINGw., $HEXw. | CHARACTER |
any date format | DATE |
any time format | TIME |
any datetime format | TIMESTAMP |
all other numeric formats | FLOAT |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.