> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/collation.md).

# COLLATION

## Syntax

```bnf
COLLATION(str)
```

## Description

Returns the collation of the string argument. If `str` is not a string, it is considered as a binary string (so the function returns 'binary'). This applies to `NULL`, too. The return value is a string in the utf8 [character set](/docs/server/reference/data-types/string-data-types/character-sets.md).

See [Character Sets and Collations](/docs/server/reference/data-types/string-data-types/character-sets.md).

## Examples

```sql
SELECT COLLATION('abc');
+-------------------+
| COLLATION('abc')  |
+-------------------+
| latin1_swedish_ci |
+-------------------+

SELECT COLLATION(_utf8'abc');
+-----------------------+
| COLLATION(_utf8'abc') |
+-----------------------+
| utf8_general_ci       |
+-----------------------+
```

## See Also

* [String literals](/docs/server/reference/sql-structure/sql-language-structure/string-literals.md)
* [CAST()](/docs/server/reference/sql-functions/string-functions/cast.md)
* [CONVERT()](/docs/server/reference/sql-functions/string-functions/convert.md)

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}
