---
title: "Literals"
description: "Write constant values in CoraDB SQL: numbers, date and time literals, bit strings, character strings, collections and NULL."
url: "https://www.coradb.ai/manual/sql/literal.html"
markdown_url: "https://www.coradb.ai/manual/markdown/sql/literal.md"
product: "CoraDB"
version: "1.0"
keywords: "sql literal, coradb literal, number literal, date literal, time literal, datetime literal, timestamp literal, datetimetz, timestamptz, bit string literal, hex literal, string literal, escape quote, collection literal, null"
---

# Literals

A literal is a constant value written directly in a statement, such as `42`, `'France'` or `DATE'2025-12-31'`. This page shows how to write each kind and which data type it produces. The examples select from `db_root`, a system table with exactly one row.


## Numbers

- An **exact** number is written with digits and an optional decimal point. It becomes an `INTEGER`, a `BIGINT` or a `NUMERIC`, depending on its size and whether it has decimals.
- An **approximate** number uses scientific notation, with `E` followed by the power of 10. It becomes a `DOUBLE`.
- A `+` or `-` sign can precede the number and the exponent.

```sql
SELECT TYPEOF(10), TYPEOF(123456789012), TYPEOF(1234234324234.23),
       TYPEOF(1.2345E15), TYPEOF(-1.2345E-15)
FROM db_root;
```

| typeof(10) | typeof(123456789012) | typeof(1234234324234.23) | typeof(1.2345E15) | typeof(-1.2345E-15) |
|---|---|---|---|---|
| integer | bigint | Numeric (15, 2) | double | double |


## Dates and times

Write the type name in front of a quoted string. The type name is not case-sensitive. With these literals you do not need conversion functions such as [TO_DATE](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_date) or [TO_DATETIME](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_datetime).

| Literal | Accepted formats | Example |
|---|---|---|
| `DATE` | `'YYYY-MM-DD'`, `'MM/DD/YYYY'` | `DATE'2025-12-31'` |
| `TIME` | `'HH:MI:SS'`, `'HH:MI:SS AM'`, `'HH:MI:SS PM'` | `TIME'14:30:05'` |
| `DATETIME` | `'YYYY-MM-DD HH:MI:SS[.msec] [AM\|PM]'`, `'MM/DD/YYYY HH:MI:SS[.msec] [AM\|PM]'` | `DATETIME'2025-12-31 14:30:05.123'` |
| `TIMESTAMP` | `'YYYY-MM-DD HH:MI:SS [AM\|PM]'`, `'MM/DD/YYYY HH:MI:SS [AM\|PM]'` | `TIMESTAMP'2025-12-31 14:30:05'` |

`msec` is milliseconds, up to three digits.

```sql
SELECT DATE'2025-12-31', DATE'12/31/2025', TIME'02:30:05 PM',
       DATETIME'12/31/2025 02:30:05.123 PM'
FROM db_root;
```

| date '2025-12-31' | date '12/31/2025' | time '02:30:05 PM' | datetime '12/31/2025 02:30:05.123 PM' |
|---|---|---|---|
| 2025-12-31 | 2025-12-31 | 14:30:05 | 2025-12-31 14:30:05.123 |

The e-commerce examples throughout this manual use the ISO form, for example `WHERE order_date >= DATE'2025-12-01'`.

### Dates and times with a time zone

The time zone types take the same formats, followed by a time zone: an offset such as `+02:00` or `+02`, or a region name such as `Europe/Bucharest` (see [SHOW TIMEZONES](https://www.coradb.ai/manual/sql/query/show.html#show-timezones)).

| Literal | Same as | Stores |
|---|---|---|
| `DATETIMETZ'...'` | `DATETIME WITH TIME ZONE '...'` | The time and its time zone. |
| `DATETIMELTZ'...'` | `DATETIME WITH LOCAL TIME ZONE '...'` | The time in UTC; it is shown in the session's time zone. |
| `TIMESTAMPTZ'...'` | `TIMESTAMP WITH TIME ZONE '...'` | The time and its time zone. |
| `TIMESTAMPLTZ'...'` | `TIMESTAMP WITH LOCAL TIME ZONE '...'` | The time in UTC; it is shown in the session's time zone. |

```text
DATETIMETZ'2025-12-31 14:30:05 +02:00'
DATETIMETZ'2025-12-31 14:30:05 Europe/Bucharest'
TIMESTAMPTZ'12/31/2025 02:30:05 PM Europe/Bucharest'
DATETIME WITH LOCAL TIME ZONE '2025-12-31 14:30:05 +02:00'
```

For how the time zone types behave, see [Date/time types with timezone](https://www.coradb.ai/manual/sql/datatype_datetime.html#datetime-types-with-timezone).


## Bit strings

A bit string can be written in binary or in hexadecimal:

- Binary: `B'...'` with the digits `0` and `1` in quotes, or `0b` followed by the digits.
- Hexadecimal: `X'...'` with hexadecimal digits in quotes, or `0x` followed by the digits.

Binary values are padded with zeros on the right to a multiple of 8 bits, and hexadecimal values to a multiple of 2 digits. All the comparisons below are true:

```sql
SELECT B'10100000' = X'a0', 0b10100000 = 0xA0, B'1' = X'80', X'a' = X'a0' FROM db_root;
```

| B'10100000'=X'a0' | B'10100000'=X'A0' | B'1'=X'80' | X'a'=X'a0' |
|---:|---:|---:|---:|
| 1 | 1 | 1 | 1 |


## Character strings

Enclose a character string in single quotes. To include a single quote, write it twice:

```sql
SELECT 'It''s shipped' FROM db_root;
```

| 'It''s shipped' |
|---|
| It's shipped |

A backslash is an ordinary character by default, so `'C:\temp'` is stored as written. Backslash escape sequences such as `\n` are available only when the [no_backslash_escapes](https://www.coradb.ai/manual/admin/config.html) parameter is set to `no`; see [Escape special characters](https://www.coradb.ai/manual/sql/datatype_string.html#escape-special-characters).

Double quotes enclose identifiers, not strings (see [Identifiers](https://www.coradb.ai/manual/sql/identifier.html#quoted-identifiers)).

A character set introducer can precede a string and a `COLLATE` clause can follow it, for example `_utf8'Blaye' COLLATE utf8_en_ci`. See [Charset introducer](https://www.coradb.ai/manual/sql/i18n_collation.html#charset-introducer).


## Collections

Values of the collection types `SET`, `MULTISET` and `LIST` (also called `SEQUENCE`) are written as elements in braces:

```text
{'c', 'c', 'b', 'a'}
```

A brace literal on its own is a `LIST` (`SEQUENCE`), which keeps duplicates and order. Stored in a `SET` column, `{'c', 'c', 'b', 'a'}` becomes `{'a', 'b', 'c'}`: duplicates are removed and the elements sorted. See [Collection types](https://www.coradb.ai/manual/sql/datatype_collection.html#collection-types).

## NULL

`NULL` (or `null`) means that there is no value. It is neither `0` nor the empty string `''`. Comparing anything with `NULL` using `=` gives `NULL`, not true or false; use `IS NULL` instead:

```sql
SELECT NULL IS NULL, NULL = 0, '' IS NULL FROM db_root;
```

| null is null | null=0 | '' is null |
|---:|---:|---:|
| 1 | NULL | 0 |

## See also

- [Data types](https://www.coradb.ai/manual/sql/datatype.html)
- [Identifiers](https://www.coradb.ai/manual/sql/identifier.html)
- [Type conversion functions](https://www.coradb.ai/manual/sql/function/typecast_fn.html)
