---
title: "RIGHT"
description: "The RIGHT SQL function extracts a substring from a text using characters from the right side."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/right
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/right
updated: 2026-08-09T00: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)) --> | | RIGHT[RIGHT]:::quoted
    RIGHT --> End((END))
```

## Purpose
The `RIGHT` SQL function extracts a substring from a text using characters from the right side. The original input text is provided when the text has less characters than the desired length.

Parameters:
- Input (`varchar2`): text to extract substring from.
- Length (`int32`): maximum length of the substring.

Returns: substring from the right side of the input as a `varchar2`.

## Examples
The following example retrieves the right three characters of a text:
```sql
select right('abcdefg', 3)

----------------
efg
```
The following example retrieves the right nine characters of a text:
```sql
select right('abcdefg', 9)

----------------
abcdefg
```