## 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 left three characters of a text:
```sql
select right('abcdefg', 3)
----------------
efg
```
The following example retrieves the left nine characters of a text:
```sql
select right('abcdefg', 9)
----------------
abcdefg
```