---
title: tinyint function
description: Learn the syntax of the tinyint function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/tinyint
---

# `tinyint` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Casts `expr` to TINYINT. This function is a synonym for `CAST(expr AS TINYINT)`. See [`cast` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/cast.md) for details.

## Syntax

```
tinyint(expr)
```

## Arguments

* `expr`: Any expression which is castable to TINYINT.

## Returns

The result is TINYINT.

If `expr` is a `STRING` that cannot be parsed as a number, Databricks raises a [CAST\_INVALID\_INPUT](https://docs.databricks.com/aws/en/error-messages/cast-invalid-input-error-class.md) error. If the value overflows the `TINYINT` range, Databricks raises a [CAST\_OVERFLOW](https://docs.databricks.com/aws/en/error-messages/error-classes.md#cast_overflow) error.

## Common error conditions

* [CAST\_INVALID\_INPUT](https://docs.databricks.com/aws/en/error-messages/cast-invalid-input-error-class.md)
* [CAST\_OVERFLOW](https://docs.databricks.com/aws/en/error-messages/error-classes.md#cast_overflow)

## Examples

```sql
> SELECT tinyint('12');
 12
> SELECT tinyint(5.4);
 5

> SELECT tinyint('abc');
  Error: CAST_INVALID_INPUT
```

## Related functions

* [`cast` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/cast.md)
