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

# Table tags

> Create, move, drop, and list names for existing table versions with SQL.

Enterprise only

Use a table tag to give an existing table version a name, such as `release-1`.
These SQL statements manage the same tags as the table SDK and REST API.
They require an Enterprise server with SQL table tag support.

## Syntax

```sql theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
CREATE TAG '<tag>' ON TABLE <table> AT VERSION <version>;
ALTER TAG '<tag>' ON TABLE <table> SET VERSION <version>;
DROP TAG '<tag>' ON TABLE <table>;
SHOW TAGS FOR TABLE <table>;
```

Tag names are single-quoted strings. Version numbers must be positive integers
that identify existing table versions; the first version is 1.

An unqualified table name uses the session's database and namespace. To choose a
different namespace or database, qualify the table name:

```sql theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
SHOW TAGS FOR TABLE analytics.events;
SHOW TAGS FOR TABLE reporting.analytics.events;
```

### Branch scope

`CREATE TAG` and `ALTER TAG` resolve version numbers on the table's main branch.
The SQL syntax has no branch selector. `SHOW TAGS` lists all tags for the table,
including tags associated with other branches; its `branch` column identifies
those tags. `DROP TAG` removes the named tag regardless of its branch.

### Privileges

The caller needs access to the table's database and namespace, plus the table
privilege for the requested statement:

| Statement | Required table privilege |
| - | - |
| `CREATE TAG`, `ALTER TAG`, `DROP TAG` | `OWNERSHIP` |
| `SHOW TAGS` | `SELECT` |

## Create a tag

Assuming `events` already has version 42, name that version `release-1`:

```sql theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
CREATE TAG 'release-1' ON TABLE events AT VERSION 42;
```

Creating a tag fails if the name already exists or the version does not exist.
Use a new name or move the existing tag with `ALTER TAG`.

## Move a tag

Point an existing tag at another version on the main branch:

```sql theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
ALTER TAG 'release-1' ON TABLE events SET VERSION 57;
```

The tag and version 57 must already exist. Moving a tag changes the version it
names without changing the table's data.

## Drop a tag

Remove a tag when its name is no longer needed:

```sql theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
DROP TAG 'release-1' ON TABLE events;
```

Dropping a tag removes its name without dropping the table or its version.
The statement fails if the tag does not exist.

Successful `CREATE TAG`, `ALTER TAG`, and `DROP TAG` statements return one row
with `operation`, `name`, and `status` columns. `name` is the tag name, and
`status` is `created`, `updated`, or `dropped`, respectively.

## List tags

```sql theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
SHOW TAGS FOR TABLE events;
```

The result has one row per tag, sorted by tag name. A table with no tags returns
zero rows with the same columns:

| Column | Arrow type | Description |
| - | - | - |
| `tag` | `Utf8` | Tag name. |
| `version` | `UInt64` | Version the tag points to. |
| `branch` | `Utf8`, nullable | Branch associated with the tag, or `NULL` for the main branch. |
| `manifest_size` | `UInt64` | Size of the tagged version's manifest file in bytes. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.