## Syntax
```mermaid
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> UUID_EXTRACT_VERSION[UUID_EXTRACT_VERSION]:::quoted
UUID_EXTRACT_VERSION --> End((END))
```
## Purpose
The `UUID_EXTRACT_VERSION` SQL function returns the version of a UUID of the variant of RFC 9562: 4 for a random UUID such as [[NEWID]] creates, 7 for a time-ordered UUID such as [[UUIDV7]] creates. The versions 1, 3, 5, 6 and 8 are those of [[UUID_GENERATE_V1]], [[UUID_GENERATE_V3]], [[UUID_GENERATE_V5]], [[UUID_GENERATE_V6]] and [[UUID_GENERATE_V8]].
The function returns `null` for a UUID of another variant, such as the empty UUID, and for `null`.
The function is available under the same name in PostgreSQL 18.
Available from release 28.0.
See also [[UUID_EXTRACT_TIMESTAMP]], [[UUID_GENERATE_V1]], [[UUID_GENERATE_V3]], [[UUID_GENERATE_V5]], [[UUID_GENERATE_V6]] and [[UUID_GENERATE_V8]].
Parameters:
- Input (`guid`): the UUID, or text of the form of a UUID.
Text which is no UUID raises `itgenduy005`; check it first with [[IS_GUID]].
Returns: the version, of data type `number`.
## Examples
The following example reads the version of a UUID of version 7:
```sql
select uuid_extract_version('019535d9-3df7-79fb-b466-fa907fa17f9e') version
-------
7
```
The following example returns `null`, since the empty UUID is no UUID of RFC 9562:
```sql
select uuid_extract_version('00000000-0000-0000-0000-000000000000') version
--------
null
```