Every column in a table has a name and a data type. The data type tells Greenplum how much physical storage to set aside for the column and the form in which the data is stored. This section includes information about Greenplum data types, null and default values, and data conversions.
SAS/ACCESS Interface to Greenplum does not directly support any data types that are not listed below. Any columns using these types are read into SAS as character strings.
For more information about Greenplum data types and to determine which data types are available for your version of Greenplum, see your Greenplum documentation.
Here are the data types that SAS/ACCESS Interface to Greenplum supports:
| CHAR(n) |
| VARCHAR(n) |
| TEXT |
| BIGINT | REAL |
| SMALLINT | FLOAT |
| INTEGER | DECIMAL | DEC | NUMERIC |
| DOUBLE PRECISION |
| DATE |
| TIME |
| TIMESTAMP |
Greenplum has a special value called NULL. A Greenplum NULL value means an absence of information and is analogous to a SAS missing value. When SAS/ACCESS reads a Greenplum NULL value, it interprets it as a SAS missing value. When loading SAS tables from Greenplum sources, SAS/ACCESS stores Greenplum NULL values as SAS missing values.
In Greenplum tables, NULL values are valid in all columns by default. There are two methods to specify a column in a Greenplum table so that it requires data:
When creating Greenplum tables with SAS/ACCESS, you can use the DBNULL= data set option to specify the treatment of NULL values. For more information about how SAS handles NULL values, see Potential Result Set Differences When Processing Null Data.
Once you know whether a Greenplum column enables NULLs or the host system provides a default value for a column that is specified as NOT NULL WITH DEFAULT, you can write selection criteria and enter values to update a table. Unless a column is defined as NOT NULL or NOT NULL DEFAULT, it enables NULL values.
To control how the DBMS handles SAS missing character values, use the NULLCHAR= and NULLCHARVAL= data set options.
The following table shows the default formats that SAS/ACCESS Interface to Greenplum assigns to SAS variables when using the LIBNAME statement to read from a Greenplum table.
These default formats are based on Greenplum column attributes.
|
Greenplum Data Type |
SAS Data Type |
Default SAS Format |
|---|---|---|
|
CHAR(n)1 |
character |
$w. |
|
VARCHAR(n)1 |
character |
$w. |
|
BYTEA |
character |
$w.3 |
|
INTEGER |
numeric |
11. |
|
SMALLINT |
numeric |
6. |
|
BIGINT |
numeric |
20. |
|
DECIMAL(p,s)2 |
numeric |
w.d |
|
NUMERIC(p,s)2 |
numeric |
w.d |
|
REAL |
numeric |
none |
|
TIME |
numeric |
TIME8.4 |
|
DATE |
numeric |
DATE9. |
|
TIMESTAMP |
numeric |
DATETIME25.6 |
| 1 n in Greenplum data types is equivalent to w in SAS formats. | ||
| 2 p and s in Greenplum numeric data types are equivalent to w and d in SAS formats. | ||
| 3 Because the Greenplum ODBC driver does the conversion, this field is displayed as if the $HEXw. format were applied. | ||
| 4 TIME values are formatted as TIME8. values unless FETCH_TWFS_AS_TIME=NO. In that case, TIME values are formatted as DATETIME25.6. values. | ||
The next table shows the default Greenplum data types that SAS/ACCESS assigns to SAS variable formats during output operations when you use the LIBNAME statement.
|
SAS Variable Format |
Greenplum Data Type |
|---|---|
|
w.d |
DECIMAL(p,s)2 |
|
$w. |
VARCHAR(n)1 |
|
datetime formats |
TIMESTAMP |
|
date formats |
DATE |
|
time formats |
TIME |
| 1 n in Greenplum data types is equivalent to w in SAS formats. | |
| 2 p and s in Greenplum numeric data types are equivalent to w and d in SAS formats. | |