---
title: "RANDOM_TEXT"
description: "The RANDOM_TEXT SQL function generates a text with pseudo-random values taken from a list of possible characters."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/random-text
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/random-text
updated: 2026-10-08T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> | | RANDOM_TEXT[RANDOM_TEXT]:::quoted
    RANDOM_TEXT --> End((END))
```

## Purpose
The `RANDOM_TEXT` SQL function generates a text with pseudo-random values taken from a list of possible characters.

See also [[RANDOM]] and [[RANDOM_BLOB]].

Parameters:
- Length (`int32`): Produce a text with this length in terms of characters, from 0 to 67,108,864.
- Candidates (`varchar2`): List of characters to choose from. The same character may appear multiple times.

Returns: A text with pseudo-random values.

## Examples
The following example generates a text of 10 pseudo-random characters taken from `abc`; the actual value differs per invocation:
```sql
select random_text(10, 'abc')

-------------------
bacbcabbca
```
The following example generates a text of 10 pseudo-random characters and retrieves the length in characters:
```sql
select length(random_text(10, '23456789ABCDEFGHJKLMNPQRSTUVWXYZ'))

-------------------
10
```