> 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/server-usage/storage-engines/mroonga/mroonga-user-defined-functions/last_insert_grn_id.md).

# last\_insert\_grn\_id

## Syntax

```
last_insert_grn_id()
```

## Description

`last_insert_grn_id` is a [user-defined function](/docs/server/server-usage/user-defined-functions.md) (UDF) included with the [Mroonga storage engine](/docs/server/server-usage/storage-engines/mroonga.md). It returns the unique Groonga id of the last-inserted record. See [Creating Mroonga User-Defined Functions](/docs/server/server-usage/storage-engines/mroonga/mroonga-user-defined-functions/creating-mroonga-user-defined-functions.md) for details on creating this UDF if required.

## Examples

```sql
SELECT last_insert_grn_id();
+----------------------+
| last_insert_grn_id() |
+----------------------+
|                    3 |
+----------------------+
```

## See Also

* [Creating Mroonga User-Defined Functions](/docs/server/server-usage/storage-engines/mroonga/mroonga-user-defined-functions/creating-mroonga-user-defined-functions.md)

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
