> 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-structure/sequences/sequence-functions.md).

# SEQUENCE Functions

{% columns %}
{% column %}
{% content-ref url="/pages/2bTC8d6PDT4xDEtOC7H7" %}
[LASTVAL](/docs/server/reference/sql-structure/sequences/sequence-functions/lastval.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
LASTVAL is a synonym for PREVIOUS VALUE FOR, returning the most recent value generated from a sequence in the current connection.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/dNWDgcXIaCqgaAxW3fd5" %}
[NEXT VALUE FOR](/docs/server/reference/sql-structure/sequences/sequence-functions/next-value-for-sequence_name.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Generate the next value of a sequence with NEXT VALUE FOR (ANSI SQL), NEXTVAL() (PostgreSQL), or sequence\_name.nextval in Oracle mode.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/5CnTY6lKHWmjFBNuPSKW" %}
[NEXTVAL](/docs/server/reference/sql-structure/sequences/sequence-functions/nextval.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
NEXTVAL is a synonym for NEXT VALUE FOR, generating the next value of a sequence.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/V2qijRrqk6mo4zhCvP8x" %}
[PREVIOUS VALUE FOR](/docs/server/reference/sql-structure/sequences/sequence-functions/previous-value-for-sequence_name.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Get the most recent value generated from a sequence in the current connection with PREVIOUS VALUE FOR (DB2), LASTVAL() (PostgreSQL), or sequence\_name.currval in Oracle mode.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/vT0zLrlr5ySeZT4SlZ21" %}
[SETVAL](/docs/server/reference/sql-structure/sequences/sequence-functions/setval.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Set the next value returned by a sequence with SETVAL(), a PostgreSQL-compatible function extended with is\_used and round arguments that never lowers the sequence below its current value.
{% endcolumn %}
{% endcolumns %}
