Core / Built-in Types
The following table lists the built-in types in CDS, and their most common mapping to ANSI SQL types, when deployed to a relational database (concrete mappings to specific databases may differ):
| CDS Type | Remarks | ANSI SQL |
|---|---|---|
UUID | RFC 4122-compliant UUIDs | NVARCHAR(36) |
Boolean | Values: true, false, null, 0, 1 | BOOLEAN |
Integer | Same as Int32 by default | INTEGER |
Int16 | Signed 16-bit integer, range [ -215 ... +215 ) | SMALLINT |
Int32 | Signed 32-bit integer, range [ -231 ... +231 ) | INTEGER |
Int64 | Signed 64-bit integer, range [ -263 ... +263 ) | BIGINT |
UInt8 | Unsigned 8-bit integer, range [ 0 ... 255 ] | TINYINT |
Decimal(p,s) | Decimal with precision p and scale s | DECIMAL |
Double | Floating point with binary mantissa | DOUBLE |
Date | e.g. 2022-12-31 | DATE |
Time | e.g. 23:59:59 | TIME |
DateTime | sec precision | TIMESTAMP |
Timestamp | µs precision, with up to 7 fractional digits | TIMESTAMP |
String (length) | Default length: 255; on HANA: 5000 | NVARCHAR |
Binary (length) | Default length: 255; on HANA: 5000 | VARBINARY |
Vector (length) | SAP HANA Cloud QRC 1/2024, or later only | REAL_VECTOR |
LargeBinary | Unlimited binary data, usually streamed at runtime | BLOB |
LargeString | Unlimited textual data, usually streamed at runtime | NCLOB |
Map | Mapped to NCLOB for HANA. | JSON type |
Default String Lengths
Lengths can be omitted, in which case default lengths are used. While this is usual in initial phases of a project, productive apps should always use explicitly defined length. The respective default lengths are configurable through the config options
cds.cdsc.defaultStringLength = 255 and cds.cdsc.defaultBinaryLength = 255.Use Attachments instead of LargeBinary
Consider using Attachments, as provided through the CAP Attachments plugins, instead of LargeBinary types for user-generated content like documents, images, etc.
See also: