---
sidebar_position: 8
title: MD_GET_DIVE_VERSION
description: Retrieve a specific historical version of a Dive including its content.
feature_stage: preview
---

Retrieves a specific version of a [Dive](/key-tasks/ai-and-motherduck/dives), including the full React component source code. Version numbers are 0-based—the first version of a Dive is version `0`.

## Syntax

```sql
SELECT * FROM MD_GET_DIVE_VERSION(
  id = 'your-dive-uuid'::UUID,
  version = 0
);
```

## Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `id` | `UUID` | Yes | The unique identifier of the Dive |
| `version` | `UINTEGER` | Yes | The version number to retrieve (0-based) |

## Return Columns

| Column | Type | Description |
|--------|------|-------------|
| `id` | `UUID` | UUID of this version |
| `version` | `UINTEGER` | Version number |
| `storage_url` | `VARCHAR` | Storage URL of the version content |
| `description` | `VARCHAR` | Version description or commit message |
| `created_at` | `TIMESTAMP WITH TIME ZONE` | When this version was created |
| `api_version` | `UINTEGER` | API version used to create this version |
| `content` | `VARCHAR` | Full JSX/React component source code |

## Examples

Read the original version of a Dive:

```sql
SELECT content
FROM MD_GET_DIVE_VERSION(
  id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'::UUID,
  version = 0
);
```

Compare version metadata:

```sql
SELECT version, description, created_at
FROM MD_GET_DIVE_VERSION(
  id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'::UUID,
  version = 2
);
```

## Errors

Returns an error if the Dive or the specified version does not exist.

## Related

- [`MD_LIST_DIVE_VERSIONS`](../md-list-dive-versions) — List all versions to find version numbers
- [`MD_GET_DIVE`](../md-get-dive) — Get the latest version of a Dive
- [`read_dive` MCP tool](/sql-reference/mcp/read-dive) — AI assistant equivalent (supports `version` parameter)
