Built-in Types
The following built-in types are provided:
CDS Type | Arguments / Remarks | Example Value | SQL (6) |
---|---|---|---|
UUID | an opaque string (1) | 'be071623-8699-4106-...' | NVARCHAR(36) |
Boolean | true | BOOLEAN | |
UInt8 | (2) | 133 | TINYINT |
Int16 | 1337 | SMALLINT | |
Int32 | 1337 | INTEGER | |
Integer | 1337 | INTEGER | |
Int64 | 1337 | BIGINT | |
Integer64 | 1337 | BIGINT | |
Decimal | (precision, scale) (3) | 15.2 | DECIMAL |
Double | 15.2 | DOUBLE | |
Date | '2021-06-27' | DATE | |
Time | '07:59:59' | TIME | |
DateTime | sec precision | '2021-06-27T14:52:23Z' | TIMESTAMP |
Timestamp | µs precision (4) | '2021-06-27T14:52:23.123Z' | TIMESTAMP |
String | (length ) (5) | 'hello world' | NVARCHAR |
Binary | (length) (5) | VARBINARY | |
LargeBinary | BLOB | ||
LargeString | 'hello world' | NCLOB | |
Map | a JSON Object | { "foo": "bar" } | (7) |
Vector | (dimensionality) (8) | REAL_VECTOR |
Remarks
(1) At runtime, UUIDs are treated as opaque values and are, for example, not converted to lower case on input. UUIDs generated in the application are RFC 4122-compliant. See Don't Interpret UUIDs! for details.
(2) Not supported on PostgreSQL, as there is no
TINYINT
. Not supported on H2, asTINYINT
is signed on H2. UseInt16
instead.
(3) Arguments
precision
andscale
are optional → if omitted a decfloat type is used
(4) Up to 7 digits of fractional seconds; if a data is given with higher precision truncation may occur
(5) Argument
length
is optional → use optionscds.cdsc.defaultStringLength
andcds.cdsc.defaultBinaryLength
to control the project-specific default length used for OData and SQL backends. If no option is specified, a hard-coded default length of 5000 for SAP HANA and 255 for all other SQL backends applies. Note that these hard-coded default lengths are only applied on database level. Specify fixed lengths to get length checks on service level and/or inbound data.
(6) Mapping to ANSI SQL types are given for comparison. Note though, that you need to have the specification of your target database in mind when considering, for example, length restrictions.
(7) SAP HANA:
NCLOB
, SQLite and H2:JSON
, Postgres:JSONB
(8) requires SAP HANA Cloud (QRC 1/2024 or later).