> ## Documentation Index
> Fetch the complete documentation index at: https://villagesql.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# vsql_nanoid extension for MySQL

> The vsql_nanoid community extension generates short URL-safe random identifiers in MySQL, 21 characters by default, with a configurable length and alphabet.

A Nano ID is 21 characters where a UUID is 36, drawn from an alphabet that is
safe in a URL without escaping. `vsql_nanoid` generates them in SQL, so a
public-facing identifier can be produced at insert time rather than in your
application.

|                              |                                                                         |
| ---------------------------- | ----------------------------------------------------------------------- |
| **Maintainer**               | [Anurag Ojha](https://github.com/intojhanurag)                          |
| **Source and documentation** | [intojhanurag/vsql-nanoid](https://github.com/intojhanurag/vsql-nanoid) |
| **License**                  | GPL-2.0                                                                 |

<Note>
  A third party writes and maintains this extension. VillageSQL does not build,
  test, or ship it, and the description below follows the maintainer's own
  documentation. Read that documentation before you rely on it.
</Note>

## Install

Build it from the repository, then install it into the server. It needs OpenSSL
for its random source.

```sql theme={null}
INSTALL EXTENSION vsql_nanoid;
```

## What it adds

| Function                      | Returns | What it does                                                       |
| ----------------------------- | ------- | ------------------------------------------------------------------ |
| `nanoid()`                    | text    | A 21-character identifier from the default alphabet, `A-Za-z0-9_-` |
| `nanoid_with(size)`           | text    | The same, at a length you choose                                   |
| `nanoid_with(size, alphabet)` | text    | The same, from an alphabet you choose                              |

## See also

* [UUIDs in MySQL](/docs/guides/uuids) — the other way to generate an opaque identifier
* [Primary key strategies](/docs/guides/primary-key-strategies) — what a random key costs on an InnoDB index
* [Available extensions](/docs/mysql-9.7/dev/extensions) — the full catalog
* [intojhanurag/vsql-nanoid](https://github.com/intojhanurag/vsql-nanoid) — source, examples, and the known limitations
