CDS Primitive Data Types

In the Data Definition Language (DDL), primitive (or core) data types are the basic building blocks that you use to define entities or structure types with DDL.

When you are specifying a design-time table (entity) or a view definition using the CDS syntax, you use data types such as String, Binary, or Integer to specify the type of content in the entity columns. CDS supports the use of the following primitive data types:

The following table lists all currently supported simple DDL primitive data types. Additional information provided in this table includes the SQL syntax required as well as the equivalent SQL and EDM names for the listed types.

Table 11: Supported SAP HANA DDL Primitive Types
Name Description SQL Literal Syntax SQL Name EDM Name
String (n) Variable-length Unicode string with a specified maximum length of n=1-1333 characters (5000 for SAP HANA specific objects). Default = maximum length. String length (n) is mandatory. 'text with “quote”' NVARCHAR String
LargeString Variable length string of up to 2 GB (no comparison) 'text with “quote”' NCLOB String
Binary(n) Variable length byte string with user-defined length limit of up to 4000 bytes. Binary length (n) is mandatory. x'01Cafe', X'01Cafe' VARBINARY Binary
LargeBinary Variable length byte string of up to 2 GB (no comparison) x'01Cafe', X'01Cafe' BLOB Binary
Integer Respective container's standard signed integer. Signed 32 bit integers in 2's complement, -2**31 .. 2**31-1. Default=NULL 13, -1234567 INTEGER Int64
Integer64 Signed 64-bit integer with a value range of -2^63 to 2^63-1. Default=NULL. 13, -1234567 BIGINT Int64
Decimal( p, s ) Decimal number with fixed precision (p) in range of 1 to 34 and fixed scale (s) in range of 0 to p. Values for precision and scale are mandatory. 12.345, -9.876 DECIMAL( p, s ) Decimal
DecimalFloat Decimal floating-point number (IEEE 754-2008) with 34 mantissa digits; range is roughly ±1e-6143 through ±9.99e+6144 12.345, -9.876 DECIMAL Decimal
BinaryFloat Binary floating-point number (IEEE 754), 8 bytes (roughly 16 decimal digits precision); range is roughly ±2.2207e-308 through ±1.7977e+308 1.2, -3.4, 5.6e+7 DOUBLE Double
LocalDate Local date with values ranging from 0001-01-01 through 9999-12-31 date'1234-12-31' DATE DateTimeOffset

Combines date and time; with time zone must be converted to offset

LocalTime Time values (with seconds precision) and values ranging from 00:00:00 through 24:00:00 time'23:59:59', time'12:15' TIME Time

For duration/period of time (==xsd:duration). Use DateTimeOffset if there is a date, too.

UTCDateTime UTC date and time (with seconds precision) and values ranging from 0001-01-01 00:00:00 through 9999-12-31 23:59:59 timestamp'2011-12-31 23:59:59' SECONDDATE DateTimeOffset

Values ending with “Z” for UTC. Values before 1753-01-01T00:00:00 are not supported; transmitted as NULL.

UTCTimestamp UTC date and time (with a precision of 0.1 microseconds) and values ranging from 0001-01-01 00:00:00 through 9999-12-31 23:59:59.9999999, and a special initial value timestamp'2011-12-31 23:59:59.7654321' TIMESTAMP DateTimeOffset

With Precision = “7”

Boolean

Represents the concept of binary-valued logic

true, false, unknown (null)

BOOLEAN

Boolean

The following table lists all the native SAP HANA primitive data types that CDS supports. The information provided in this table also includes the SQL syntax required (where appropriate) as well as the equivalent SQL and EDM names for the listed types.

Table 12: Supported Native SAP HANA Data Types
Data Type * Description SQL Literal Syntax SQL Name EDM Name
ALPHANUM Variable-length character string with special comparison - ALPHANUMERIC -
SMALLINT Signed 16-bit integer -32768, 32767 SMALLINT Int16
TINYINT Unsigned 8-bit integer 0, 255 TINYINT Byte
REAL 32-bit binary floating-point number - REAL Single
SMALLDECIMAL 64-bit decimal floating-point number - SMALLDECIMAL Decimal
VARCHAR Variable-length ASCII character string with user-definable length limit n - VARCHAR String
CLOB Large variable-length ASCII character string, no comparison - CLOB String
BINARY Byte string of fixed length n - BINARY Blob
ST_POINT 0-dimensional geometry representing a single location - - -
ST_GEOMETRY Maximal supertype of the geometry type hierarchy; includes ST_POINT - - -

The following example shows the native SAP HANA data types that CDS supports; the code example also illustrates the mandatory syntax.

@nokey
entity SomeTypes {
  a : hana.ALPHANUM(10);
  b : hana.SMALLINT;
  c : hana.TINYINT;
  d : hana.SMALLDECIMAL;
  e : hana.REAL;
  h : hana.VARCHAR(10);
  i : hana.CLOB;
  j : hana.BINARY(10);
  k : hana.ST_POINT;
  l : hana.ST_GEOMETRY;
};