Core / Built-in Types
The following table lists the built-in types available to all CDS models, and can be used to define entity elements or custom types as follows:
cds
entity Books {
key ID : UUID;
title : String(111);
stock : Integer;
price : Price;
}
type Price : Decimal;
These types are used to define the structure of entities and services, and are mapped to respective database types when the model is deployed.
CDS Type | Remarks | ANSI SQL (1) |
---|---|---|
UUID | CAP generates RFC 4122-compliant UUIDs (2) | 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 (3) |
Decimal (prec , scale ) | A decfloat type is used if arguments are omitted | DECIMAL |
Double | Floating point with binary mantissa | DOUBLE |
Date | e.g. 2022-12-31 | DATE |
Time | e.g. 24: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 (4) | NVARCHAR |
Binary (length ) | Default length: 255; on HANA: 5000 (5) | VARBINARY |
LargeBinary | Unlimited data, usually streamed at runtime | BLOB |
LargeString | Unlimited data, usually streamed at runtime | NCLOB |
Map | Mapped to NCLOB for HANA. | JSON type |
Vector (dimension ) | Requires SAP HANA Cloud QRC 1/2024, or later | REAL_VECTOR |
(1) Concrete mappings to specific databases may differ.
(2) See also Best Practices.
(3) Not available on PostgreSQL and H2.
(4) Configurable through
cds.cdsc.defaultStringLength
.(5) Configurable through
cds.cdsc.defaultBinaryLength
.