# Literals

A literal is a value written directly into a query, rather than retrieved from the database or computed from other values. Every literal is a constant of a single [value type](../../value-types/index.md). The literal syntax accepted by each value type is documented on that value type’s page.

## [](#_usage)Usage

Literals may be used wherever a value of their type is expected.

Supplying an attribute value on insertion:

```typeql
#!test[schema]
#{{
define
  attribute start-date value date;
  entity project, owns start-date;
#}}
#!test[write]
insert
  $p isa project, has start-date 2024-03-30;
```

As an operand in an expression or comparison:

```typeql
#!test[read]
match
  $p isa project, has start-date $d;
  $d >= 2024-01-01;
  let $elapsed = 2025-01-01 - $d;
```

As an argument to a [value constraint](../../annotations/index.md):

```typeql
#!test[schema]
define
  attribute rating value integer @range(1..5);
```

Literals may also be passed to [function calls](../function-calls/index.md) by first binding them to a variable, since function arguments are always variables rather than expressions.

## [](#_type_inference)Type inference

Because a literal’s value type is fixed by its syntax, it determines the type of any expression it takes part in. An expression combining literals of incompatible value types fails at query compilation. See [comparisons](../../statements/comparisons/index.md) for which value types may be compared with one another.

Numeric literals distinguish `integer`, `double`, and `decimal` by syntax: `1` is an `integer`, `1.0` a `double`, and `1.0dec` a `decimal`. See the [Decimal](../../value-types/decimal/index.md) and [Double](../../value-types/double/index.md) pages for the distinction between them.

[Expressions](../index.md) [Value operations](../value-operations/index.md)

[Edit on GitHub](https://github.com/typedb/typedb-docs/edit/3.x-development/typeql-reference/modules/ROOT/pages/expressions/literals.adoc) Edit this page on GitHub.