---
title: Serve lakehouse data with synced tables
description: Serve lakehouse data through Lakebase for operational analytics and real-time applications
canonical_url: https://docs.databricks.com/aws/en/oltp/projects/sync-tables
---

# Serve lakehouse data with synced tables

Synced tables let you serve analytics-grade data from Unity Catalog through Lakebase Postgres. Unity Catalog tables sync into Postgres so applications can query lakehouse data directly with low latency. This process is commonly known as reverse extract, transform, and load (ETL). The lakehouse is optimized for analytics and enrichment, while Lakebase is designed for operational workloads that require fast lookup-style queries and full ACID transactions. Synced tables bridge the gap between analytical storage and operational systems by keeping your data ready to serve in real-time applications.

![Architecture diagram showing data flow from lakehouse to Lakebase to applications](https://docs.databricks.com/aws/en/images/oltp/reverse-etl-architecture.png)

## Example use cases

You can use synced tables for data-serving use cases such as:

* Personalization engines that serve fresh user profiles to Databricks Apps
* Applications that serve model predictions or feature values computed in the lakehouse
* Customer-facing dashboards that serve KPIs in real time
* Fraud detection services that serve risk scores for immediate action
* Support tools that serve enriched customer records from lakehouse data

## <a id="sources" />Supported sources

Synced tables support the following Unity Catalog source types:

* Managed and external Delta tables
* Managed and external Iceberg tables
* Views and materialized views

## How it works

Databricks **synced tables** create a managed copy of your Unity Catalog data in Lakebase. When you create a synced table, you get:

1. A synced table in Unity Catalog that references the sync pipeline
2. **A Postgres table in Lakebase** (read-only, queryable by your applications)

![Diagram showing the three-table relationship in synced tables](https://docs.databricks.com/aws/en/images/oltp/reverse-etl-three-table-flow.png)

For example, you can sync gold tables, engineered features, or ML outputs from `analytics.gold.user_profiles` into a new synced table `analytics.gold.user_profiles_synced`. In Postgres, the Unity Catalog schema name becomes the Postgres schema name, so this appears as `gold.user_profiles_synced`:

```sql title="PostgreSQL"
SELECT * FROM gold.user_profiles_synced WHERE user_id = 12345;
```

Applications connect with standard Postgres drivers and query the synced data alongside their own operational state, handling inserts, updates, and deletes on their own tables in the same database.

Sync pipelines use managed Lakeflow pipelines to continuously update both the Unity Catalog synced table and the Postgres table with changes from the source table. Each sync can use up to 16 connections to your Lakebase database. Connection limits depend on compute size. See [Compute specifications](https://docs.databricks.com/aws/en/oltp/projects/manage-computes.md#compute-spec).

> [!WARNING]
>
> While it's possible to modify a synced table directly in Postgres, Databricks strictly recommends running only read queries to protect data integrity with the source. For supported operations on synced tables, see [Operations allowed on synced tables in Postgres](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#synced-table-postgres-ops).

### <a id="ltap-direct-writes" />Accelerated sync with LTAP Direct Writes

LTAP Direct Writes is an optional synced table setting that speeds up large loads. It's part of the [LTAP architecture](https://docs.databricks.com/aws/en/oltp/projects/ltap-overview.md). It's off by default and you opt in per synced table by selecting **LTAP Direct Writes** under **Synchronization settings** in the **Create synced table** dialog. When enabled, it writes data directly into the storage layer backing your Lakebase branch instead of routing the bulk write through the live compute endpoint, so loads finish faster and don't add query load to the endpoint while they run.

What LTAP Direct Writes accelerates depends on the sync mode:

* **All modes**: The initial load. Every synced table starts by loading a full copy of the source, and that first load uses LTAP Direct Writes.
* **Snapshot**: Every subsequent sync, because **Snapshot** mode runs a full refresh each time.
* **Triggered** and **Continuous**: The initial load only. Later updates are applied incrementally through Change Data Feed, not as bulk loads.

> [!NOTE]
>
> LTAP Direct Writes is supported on Lakebase projects running Postgres 16, 17, or 18. You select LTAP Direct Writes when you [create a synced table](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#create-a-synced-table), so you can't add it to an existing synced table. To use LTAP Direct Writes with an existing synced table, delete the synced table and create a new one.

### <a id="modes" />Sync modes

Choose the right sync mode based on your application needs:

| Mode           | Description                                          | When to use                                                                                       | Performance                                              |
| -------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| **Snapshot**   | One-time copy of all data                            | Source changes >10% of rows per cycle                                                             | 10x more efficient if modifying >10% of source data      |
| **Triggered**  | Scheduled updates that run on demand or at intervals | Source rows change on a known cadence. Inserts, updates, and deletes are propagated each refresh. | Good cost/lag balance. Expensive if run \<5min intervals |
| **Continuous** | Real-time streaming with seconds of latency          | Changes must appear in Lakebase in near real time                                                 | Lowest lag, highest cost. Minimum 15-second intervals    |

In the **Create synced table** dialog, **Snapshot** and **Triggered** are both **On-demand** sync modes, available under **Advanced settings**, while **Continuous** is a separate mode.

The source requirement depends on the sync mode:

* **Snapshot** copies all data on each sync, so the source only needs to support `SELECT *`.
* **Triggered** and **Continuous** apply row-level changes incrementally, so the source must provide a change data feed. Enable write-time [change data feed](https://docs.databricks.com/aws/en/tables/features/change-data-feed.md) on the source, or use Automatic change data feed. If a Triggered or Continuous source has no change data feed, the UI shows a warning with the exact `ALTER TABLE` command to run.

[Automatic change data feed](https://docs.databricks.com/aws/en/tables/features/change-data-feed.md#auto-cdf) computes row-level changes at read time instead of requiring write-time change data feed on the source. This lets more source types, including managed Apache Iceberg v3 tables, sync in **Triggered** or **Continuous** mode. For the source types that automatic change data feed supports, see the [automatic change data feed](https://docs.databricks.com/aws/en/tables/features/change-data-feed.md#auto-cdf) documentation.

## <a id="create-a-synced-table" />Create a synced table

### Prerequisites

You need:

* A Databricks workspace with Lakebase enabled.
* A Lakebase project (see [Create a project](https://docs.databricks.com/aws/en/oltp/projects/manage-projects.md#create-projects)).
* A Unity Catalog table to sync.
* Permissions to create synced tables. You need **USE\_SCHEMA** and **CREATE\_TABLE** on any schema you use. To grant these privileges, see [Manage privileges in Unity Catalog](https://docs.databricks.com/aws/en/data-governance/unity-catalog/manage-privileges/index.md#grant-perms).

For **Triggered** or **Continuous** modes, the source must provide a change data feed. Either enable legacy change data feed on an eligible Delta Lake source table, or use [automatic change data feed](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#modes) for sources such as managed Apache Iceberg v3 tables.

To enable write-time change data feed on a Delta source table, run:

```sql title="Databricks SQL"
ALTER TABLE your_catalog.your_schema.your_table
SET TBLPROPERTIES (delta.enableChangeDataFeed = true)
```

Before you create a synced table, review the following:

* **Source**: Supported source types are listed in [Supported sources](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#sources).
* **Names and limits**: Naming rules, connection usage, and per-source limits are listed in [Capacity planning](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#capacity).
* **Column types**: Type mappings, unsupported types, and characters that cause sync failures are covered in [Data types and compatibility](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#data-types).
* **Creator identity**: The identity that creates the synced table is granted access to it, and you can't reassign that access later. See [Access for the user who creates a synced table](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#manage-creator-access).

#### UI

1. In Lakehouse, go to **Catalog** in the workspace sidebar and select the Unity Catalog table you want to sync.

   ![Catalog Explorer showing a selected table](https://docs.databricks.com/aws/en/images/oltp/reverse-etl-step1-catalog.png)

2. Click **Create** > **Synced table** from the table details view.

   ![Create button dropdown showing Synced table option](https://docs.databricks.com/aws/en/images/oltp/reverse-etl-create-dropdown.png)

3. In the **Create synced table** dialog, configure the following sections, then click **Create**:

   **Destination**

   * **Name**: Select the catalog and schema for the synced table, then enter a table name. This creates both a Unity Catalog synced table and a Postgres table you can query. The catalog and schema lists only include Unity Catalog schemas where you have **USE\_SCHEMA** and **CREATE\_TABLE** privileges. If you don't see a schema you expect, confirm your permissions with your catalog admin.
   * **Lakebase Postgres Database**: Set **Database type** to **Autoscaling**, then select your **Project**, **Branch**, and **Postgres database**.

   **Synchronization settings**

   * **Sync mode**: Select **On-demand** or **Continuous**. For **On-demand**, expand **Advanced settings** and choose **Snapshot** or **Triggered**. See [sync modes](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#modes) for guidance.

   - **LTAP Direct Writes**: (Optional) Select this checkbox to accelerate the initial load. This option is supported on Lakebase projects running Postgres 16, 17, or 18. See [Accelerated sync with LTAP Direct Writes](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#ltap-direct-writes).

   **Pipeline settings**

   * **Pipeline**: Select **Create new** to create a pipeline for this synced table, or **Use existing** to reuse one.
   * **Serverless usage policy**: (Optional) Select a serverless usage policy for the sync pipeline.

   **Schema**

   * **Primary key**: Verify the primary key (usually auto-detected). Leave **Unique** selected if each primary key value is unique in the source. If primary key values can repeat, clear **Unique** and set a **Timeseries Key**. You can't change the primary key or timeseries key after you create the synced table.

     > [!IMPORTANT]
     >
     > Columns in the primary key are not nullable in the synced table. Rows with nulls in primary key columns are *excluded from the sync*.

   * **Timeseries Key**: (Optional) When primary key values can repeat in the source, select a column to configure deduplication. The synced table then contains only the row with the latest timeseries key value for each primary key. For the failure mode without a timeseries key, see [Duplicate keys](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#capacity).

   - **Customize column types**: (Optional) Override how source columns map to Postgres types. If you map columns to `vector` or `halfvec`, install a vector extension in the destination database first. See [Custom type mappings](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#custom-type-mappings).

   If you chose **Triggered** or **Continuous** and haven't enabled Change Data Feed yet, you'll see a warning with the exact command to run.

4. Monitor the synced table in **Catalog**. The **Overview** tab shows sync status, configuration, pipeline status, and last sync timestamp. Use **Sync now** for manual refresh.

#### CLI

```bash
databricks postgres create-synced-table my-catalog.sales.orders \
  --json '{
    "spec": {
      "source_table_full_name": "main.sales.orders",
      "branch": "projects/my-project/branches/production",
      "primary_key_columns": ["order_id"],
      "scheduling_policy": "SNAPSHOT",
      "postgres_database": "mydb",
      "create_database_objects_if_missing": true
    }
  }'
```

The `SYNCED_TABLE_ID` positional argument uses the format `catalog.schema.table`. In Postgres, the table `{table}` is created in schema `{schema}`, inside the database you set with `postgres_database` (here, `mydb`). The command waits for the operation to complete by default. For all available options, see [databricks postgres create-synced-table](https://docs.databricks.com/aws/en/dev-tools/cli/reference/postgres-commands.md#databricks-postgres-create-synced-table).

To override default column type mappings, add `type_overrides` to `spec`. See [Custom type mappings](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#custom-type-mappings).

#### Python SDK

```python
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.postgres import (
    SyncedTable,
    SyncedTableSyncedTableSpec,
    SyncedTableSyncedTableSpecSyncedTableSchedulingPolicy,
)

w = WorkspaceClient()

synced_table = w.postgres.create_synced_table(
    synced_table=SyncedTable(spec=SyncedTableSyncedTableSpec(
        source_table_full_name="main.sales.orders",
        branch="projects/my-project/branches/production",
        primary_key_columns=["order_id"],
        scheduling_policy=SyncedTableSyncedTableSpecSyncedTableSchedulingPolicy.SNAPSHOT,
        postgres_database="mydb",
        create_database_objects_if_missing=True,
    )),
    synced_table_id="my-catalog.sales.orders",
).wait()

print(f"Synced table created: {synced_table.name}")
```

The `synced_table_id` uses the format `catalog.schema.table` and becomes the Unity Catalog synced table name. In Postgres, the table `{table}` is created in schema `{schema}`, inside the database you set with `postgres_database` (here, `mydb`).

#### Java SDK

```java
import com.databricks.sdk.WorkspaceClient;
import com.databricks.sdk.service.postgres.*;
import java.util.List;

WorkspaceClient w = new WorkspaceClient();

SyncedTable syncedTable = w.postgres().createSyncedTable(
    new CreateSyncedTableRequest()
        .setSyncedTableId("my-catalog.sales.orders")
        .setSyncedTable(new SyncedTable()
            .setSpec(new SyncedTableSyncedTableSpec()
                .setSourceTableFullName("main.sales.orders")
                .setBranch("projects/my-project/branches/production")
                .setPrimaryKeyColumns(List.of("order_id"))
                .setSchedulingPolicy(SyncedTableSyncedTableSpecSyncedTableSchedulingPolicy.SNAPSHOT)
                .setPostgresDatabase("mydb")
                .setCreateDatabaseObjectsIfMissing(true))))
    .waitForCompletion();

System.out.println("Synced table created: " + syncedTable.getName());
```

#### curl

```bash
curl -X POST "https://your-workspace.cloud.databricks.com/api/2.0/postgres/synced_tables?synced_table_id=my-catalog.sales.orders" \
  -H "Authorization: Bearer ${DATABRICKS_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "spec": {
      "source_table_full_name": "main.sales.orders",
      "branch": "projects/my-project/branches/production",
      "primary_key_columns": ["order_id"],
      "scheduling_policy": "SNAPSHOT",
      "postgres_database": "mydb",
      "create_database_objects_if_missing": true
    }
  }'
```

This returns a long-running operation. Poll the returned `name` field until `done: true`. See [Long-running operations](https://docs.databricks.com/aws/en/oltp/projects/api-usage.md#long-running-operations). For authentication setup, see [Authentication](https://docs.databricks.com/aws/en/oltp/projects/api-usage.md#setup-auth).

## <a id="schedule-trigger" />Schedule or trigger subsequent syncs

The initial load runs automatically when you create a synced table. After that, how syncs run depends on the sync mode:

* **Continuous** mode streams changes as they happen. You don't need to trigger syncs.
* **Snapshot** and **Triggered** modes sync only when triggered. To run a sync manually, open the synced table in **Catalog** and click **Sync now** on the **Overview** tab. To run syncs automatically, add the synced table's pipeline to a job in Lakeflow Jobs as a **Database Table Sync pipeline** task, then configure the job with one of the following triggers:
  * [Trigger on source table updates](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#trigger-on-source-table-updates): Best for **Triggered** mode.
  * [Trigger on a schedule](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#trigger-on-a-schedule): Best for **Snapshot** mode.

### <a id="trigger-on-source-table-updates" />Trigger on source table updates

Fires the job when the source Unity Catalog table is updated. With **Triggered** mode, only new changes are applied incrementally, giving near-real-time freshness without the always-on cost of Continuous mode.

1. In your workspace, click ![Workflows icon.](https://docs.databricks.com/aws/en/images/product-icons/WorkflowsIcon.svg) **Jobs & Pipelines** in the sidebar.
2. Click **Create job** or open an existing job.
3. On the **Tasks** tab, click **+ Add another task type**.
4. Under **Ingestion and Transformation**, select **Database Table Sync pipeline**.
5. In the **Pipeline** field, select the pipeline associated with your synced table.
6. Under **Schedules & Triggers**, click **Add trigger**.
7. Select **Table update** as the trigger type.
8. Under **Tables**, select the source Unity Catalog table to monitor.
9. Click **Save**.

### <a id="trigger-on-a-schedule" />Trigger on a schedule

Runs the sync at a fixed cadence. Well-suited for **Snapshot** mode, where a nightly or weekly full refresh is typically the most efficient pattern.

1. In your workspace, click ![Workflows icon.](https://docs.databricks.com/aws/en/images/product-icons/WorkflowsIcon.svg) **Jobs & Pipelines** in the sidebar.
2. Click **Create job** or open an existing job.
3. On the **Tasks** tab, click **+ Add another task type**.
4. Under **Ingestion and Transformation**, select **Database Table Sync pipeline**.
5. In the **Pipeline** field, select the pipeline associated with your synced table.
6. Under **Schedules & Triggers**, click **Add trigger**.
7. Select **Scheduled** as the trigger type.
8. Set your cron schedule and timezone, then click **Save**.

## Check sync status

To check the current state and last sync time of a synced table:

> [!NOTE]
>
> During a sync, the pipeline performs all of its data processing while it reports the `INITIALIZING` event. A large sync can report `INITIALIZING` for the full run. This is expected and does not mean the pipeline is stuck.

### UI

In **Catalog**, navigate to your synced table and select the **Overview** tab. It shows the current sync state, pipeline status, and last sync timestamp.

### Python SDK

```python
from databricks.sdk import WorkspaceClient

w = WorkspaceClient()

table = w.postgres.get_synced_table("synced_tables/my-catalog.sales.orders")
print(f"State: {table.status.detailed_state}")
print(f"Last sync: {table.status.last_sync_time}")
print(f"Message: {table.status.message}")
```

### Java SDK

```java
import com.databricks.sdk.WorkspaceClient;
import com.databricks.sdk.service.postgres.SyncedTable;

WorkspaceClient w = new WorkspaceClient();

SyncedTable table = w.postgres().getSyncedTable("synced_tables/my-catalog.sales.orders");
System.out.println("State: " + table.getStatus().getDetailedState());
System.out.println("Last sync: " + table.getStatus().getLastSyncTime());
System.out.println("Message: " + table.getStatus().getMessage());
```

### curl

```bash
curl "https://your-workspace.cloud.databricks.com/api/2.0/postgres/synced_tables/my-catalog.sales.orders" \
  -H "Authorization: Bearer ${DATABRICKS_TOKEN}"
```

## <a id="lineage" />View synced table lineage

When you create a synced table, Unity Catalog records lineage from the source table to the synced table, with the sync pipeline as the associated entity. Use lineage to trace where the data in a synced table comes from, or to find which synced tables depend on a source table before you change it.

Synced table lineage has the following limitations:

* Lineage is table-level only. Column-level lineage isn't recorded.
* Lineage ends at the Unity Catalog synced table. The Postgres table in Lakebase doesn't appear in the lineage graph, and queries that applications run against the Postgres table aren't recorded.
* Lineage is recorded when the synced table is created. Synced tables created before lineage support was available don't show lineage. To record lineage for an older synced table, delete it and [create it again](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#create-a-synced-table). Recreating a synced table runs a full initial sync.
* Lineage is matched by table name. If you recreate a synced table with the same name, lineage can also show the sync pipeline of the deleted synced table.
* If a synced table also appears in a database catalog (see [Catalog integration](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#catalog-integration)), lineage appears only on the synced table in the catalog where you created it.

### UI

1. In your workspace, click ![Data icon.](https://docs.databricks.com/aws/en/images/product-icons/DataIcon.svg) **Catalog**.

2. Search or browse for your synced table or its source table.

3. Select the **Lineage** tab. The source table appears as an upstream table. The sync pipeline appears as a **Synced table** pipeline entry in both directions: upstream because it writes to the synced table, and downstream because sync runs read from the synced table. Pipeline entries are the assets associated with lineage, not additional tables.

   ![Lineage tab for a synced table showing the upstream source table and the sync pipeline](https://docs.databricks.com/aws/en/images/oltp/synced-table-lineage-tab.png)

4. To view an interactive graph, click **See lineage graph**. The graph shows the source table connected to the synced table through the sync pipeline. The **Consumers** node groups Databricks assets that read the synced table, such as notebooks, jobs, and the sync pipeline. Applications that query the Postgres table don't appear.

   ![Lineage graph showing a source table connected to a synced table](https://docs.databricks.com/aws/en/images/oltp/synced-table-lineage-graph.png)

### System tables

Query the `system.access.table_lineage` system table. Lineage records for synced tables have a `target_type` of `TABLE` and an `entity_type` of `PIPELINE`, and `entity_id` is the ID of the sync pipeline. Lineage appears in Catalog Explorer right away, but new records can take some time to appear in the system table.

To find the source of a synced table:

```sql title="SQL"
SELECT DISTINCT source_table_full_name, entity_id AS pipeline_id
FROM system.access.table_lineage
WHERE target_table_full_name = 'analytics.gold.user_profiles_synced';
```

To find all synced tables that depend on a source table, for example before you change the source table's schema:

```sql title="SQL"
SELECT DISTINCT l.target_table_full_name, l.entity_id AS pipeline_id
FROM system.access.table_lineage l
JOIN system.information_schema.tables t
  ON l.target_table_full_name = concat_ws('.', t.table_catalog, t.table_schema, t.table_name)
WHERE l.source_table_full_name = 'analytics.gold.user_profiles'
  AND l.entity_type = 'PIPELINE'
  AND t.data_source_format = 'POSTGRESQL_FORMAT';
```

Synced tables have a `data_source_format` of `POSTGRESQL_FORMAT`, so the join limits results to synced tables. Each sync also records reads of the source table by the sync pipeline, with an empty `target_table_full_name`. The join excludes these records. The system table can also contain repeated records for the same lineage, so both queries use `DISTINCT`.

For details on lineage requirements, permissions, and retention, see [Lineage in Unity Catalog](https://docs.databricks.com/aws/en/data-governance/unity-catalog/data-lineage.md). For the full system table schema, see [Lineage system tables reference](https://docs.databricks.com/aws/en/admin/system-tables/lineage.md).

## <a id="data-types" />Data types and compatibility

Unity Catalog data types are mapped to Postgres types when creating synced tables. Complex types (ARRAY, MAP, STRUCT) and VARIANT are stored as JSONB in Postgres.

| Source column type                    | Postgres column type        |
| ------------------------------------- | --------------------------- |
| BIGINT                                | BIGINT                      |
| BINARY                                | BYTEA                       |
| BOOLEAN                               | BOOLEAN                     |
| DATE                                  | DATE                        |
| DECIMAL(p,s)                          | NUMERIC                     |
| DOUBLE                                | DOUBLE PRECISION            |
| FLOAT                                 | REAL                        |
| INT                                   | INTEGER                     |
| INTERVAL                              | INTERVAL                    |
| SMALLINT                              | SMALLINT                    |
| STRING                                | TEXT                        |
| TIMESTAMP                             | TIMESTAMP WITH TIME ZONE    |
| TIMESTAMP\_NTZ                        | TIMESTAMP WITHOUT TIME ZONE |
| TINYINT                               | SMALLINT                    |
| ARRAY\<elementType>                   | JSONB                       |
| MAP\<keyType,valueType>               | JSONB                       |
| STRUCT\<fieldName\:fieldType\[, ...]> | JSONB                       |
| VARIANT                               | JSONB                       |

> [!NOTE]
>
> GEOGRAPHY, GEOMETRY, and OBJECT types are not supported.

### <a id="custom-type-mappings" />Custom type mappings

When you create a synced table, you can override the default Delta-to-Postgres type mapping for specific columns with `type_overrides`.

> [!NOTE]
>
> The `vector` and `halfvec` types require a vector extension in the destination database. Creating the synced table does not install extensions, so install one before you create the synced table. Use [lakebase\_vector](https://docs.databricks.com/aws/en/oltp/projects/lakebase-vector.md#install), which adds ANN vector search through Lakebase Search and installs [pgvector](https://github.com/pgvector/pgvector) as a dependency:
>
> ```sql title="PostgreSQL"
> CREATE EXTENSION IF NOT EXISTS lakebase_vector CASCADE;
> ```
>
> To use the `vector` and `halfvec` types without Lakebase Search, install pgvector on its own with `CREATE EXTENSION IF NOT EXISTS vector;`. The `varchar` type requires no extension.

| Source column type              | Postgres type | Size                | Definition (`pg_type`)     | Example use case                                                                                                                                                            |
| ------------------------------- | ------------- | ------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ARRAY<FLOAT>`, `ARRAY<DOUBLE>` | `vector(n)`   | Embedding dimension | `PG_SPECIFIC_TYPE_VECTOR`  | Store embeddings as a `vector` instead of `JSONB`, ready for similarity search with [lakebase\_vector](https://docs.databricks.com/aws/en/oltp/projects/lakebase-vector.md) |
| `ARRAY<FLOAT>`, `ARRAY<DOUBLE>` | `halfvec(n)`  | Embedding dimension | `PG_SPECIFIC_TYPE_HALFVEC` | Half-precision embeddings at roughly half the storage of `vector`                                                                                                           |
| `STRING`                        | `varchar(n)`  | Maximum length      | `PG_SPECIFIC_TYPE_VARCHAR` | Map to a length-bounded `varchar` instead of the default `TEXT`                                                                                                             |

> [!NOTE]
>
> `size` is required for every type in this table. Valid ranges are:
>
> * `vector` and `halfvec`: 1 to 16,000, the number of embedding dimensions.
> * `varchar`: 1 to 10,485,760, the maximum character length.

Custom type mappings are configurable when you create a synced table. In the UI, use **Customize column types** under **Schema** in the **Create synced table** dialog. In the API, CLI, and Databricks SDKs, use `type_overrides`.

For a source table `main.docs.chunks(id BIGINT, title STRING, embedding ARRAY<FLOAT>)`, the following maps `title` to `varchar(256)` and `embedding` to `vector(1024)` in Postgres:

```bash
databricks postgres create-synced-table main.docs.chunks_pg \
  --json '{
    "spec": {
      "source_table_full_name": "main.docs.chunks",
      "branch": "projects/my-project/branches/production",
      "primary_key_columns": ["id"],
      "scheduling_policy": "SNAPSHOT",
      "postgres_database": "mydb",
      "create_database_objects_if_missing": true,
      "type_overrides": [
        { "column_name": "title", "pg_type": "PG_SPECIFIC_TYPE_VARCHAR", "size": 256 },
        { "column_name": "embedding", "pg_type": "PG_SPECIFIC_TYPE_VECTOR", "size": 1024 }
      ]
    }
  }'
```

Without the override, `title` would be `TEXT` and `embedding` would be `JSONB`.

### Handle invalid characters

Certain characters like null bytes (0x00) are allowed in Unity Catalog STRING, ARRAY, MAP, or STRUCT columns but not supported in Postgres TEXT or JSONB columns. This can cause sync failures with errors like:

```
ERROR: invalid byte sequence for encoding "UTF8": 0x00
ERROR: unsupported Unicode escape sequence DETAIL: \u0000 cannot be converted to text
```

* The first error occurs when a null byte appears in a top-level string column, which maps directly to Postgres `TEXT`.
* The second error occurs when a null byte appears in a string nested inside a complex type (`STRUCT`, `ARRAY`, or `MAP`), which is serialized as `JSONB`. During serialization, all strings are cast to Postgres `TEXT`, where `\u0000` is disallowed.

**Solutions:**

* **Sanitize string fields**: Remove unsupported characters before syncing. For null bytes in STRING columns:

  ```sql
  SELECT REPLACE(column_name, CAST(CHAR(0) AS STRING), '') AS cleaned_column FROM your_table
  ```

* **Convert to BINARY**: For STRING columns where preserving raw bytes is necessary, convert to BINARY type.

## <a id="capacity" />Capacity planning

When planning your synced tables implementation, consider these resource requirements:

* **Connection usage**: Each synced table uses up to 16 connections to your Lakebase database, which count toward the project's connection limit.
* **Size quota**: Total logical data across all synced tables counts toward the branch's [database storage quota](https://docs.databricks.com/aws/en/oltp/projects/manage-projects.md#storage-quota). Contact Databricks Support if you need a larger quota. Individual tables don't have a quota, but Databricks recommends not exceeding 1 TB for tables requiring refreshes.
* **Full-refresh size**: When triggering a full-refresh, the old version in Postgres is not deleted until the new sync completes. Both versions temporarily count toward the logical database size quota during the refresh.
* **Tables per source**: A single source table can have up to 20 synced tables.
* **Naming requirements**: Database, schema, and table names may only contain alphanumeric characters and underscores (`[A-Za-z0-9_]+`).
* **Source identifier guidance**: Avoid using uppercase letters or special characters in column or table names in the source Unity Catalog table. If you keep them, you must quote those identifiers when referencing them in Postgres.
* **Schema evolution**: Only additive schema changes (like adding columns) are supported for Triggered and Continuous modes.
* **Changing the table definition**: Updating a synced table's definition in place isn't supported through any interface (UI, SDKs, CLI, REST API, Terraform, or DABs). To change the primary key or timeseries key, or to make a non-additive schema change, delete the synced table and create a new one.
* **Duplicate keys**: If two rows have the same primary key in the source table, the sync pipeline fails unless you configure deduplication using a [timeseries key](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#create-a-synced-table).
* **API idempotency**: Synced table APIs are idempotent, so retry on transient errors to ensure timely operations.
* **Update rate**: For Lakebase the sync pipeline supports Continuous and Triggered writes at approximately 150 rows per second per Capacity Unit (CU) and Snapshot writes at up to 2,000 rows per second per CU.

## <a id="synced-table-postgres-ops" />Operations allowed on synced tables in Postgres

Databricks recommends performing only the following operations in Postgres for synced tables to prevent accidental overwrites or data inconsistencies:

* Read-only queries
* Creating indexes (see [Add indexes to a synced table](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#synced-table-indexes))
* Dropping the table (to free up space after removing the synced table from Unity Catalog)

While it's possible to modify synced tables in Postgres in other ways, it interferes with the synchronization pipeline.

### <a id="synced-table-indexes" />Add indexes to a synced table

A synced table is created with a primary key index. To add other indexes, create them in Postgres after the table exists. For example, to support containment queries on a JSONB column, such as a column synced from a VARIANT source column, create a GIN index:

```sql title="PostgreSQL"
CREATE INDEX orders_payload_gin ON sales.orders USING GIN (payload);
```

Indexes you create on a synced table persist across syncs. Every full load, including each **Snapshot** sync and any full refresh, rebuilds your indexes, so each additional index adds time to those syncs. In **Triggered** and **Continuous** modes, each index also slows incremental updates.

To create indexes, you must be the synced table's owner or creator, the `databricks_superuser`, or a user added as a manager of the synced table. See [Manage synced table operations](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#manage-table-ops).

Keep the following in mind when you create indexes:

* **Synced tables are partitioned tables.** Postgres doesn't support `CREATE INDEX CONCURRENTLY` on a partitioned table, so use `CREATE INDEX` instead. `CREATE INDEX` blocks writes to the table, including writes from the sync pipeline, until the build finishes. If the build takes more than 20 minutes while a sync is waiting, the sync fails and isn't retried automatically. Queries can still read the table, unless a full load is waiting to swap in refreshed data. On large tables, create indexes when no sync is running.
* **Run long index builds from a Postgres client.** Building an index on a large table can take a long time. Run the build from a client such as [psql](https://docs.databricks.com/aws/en/oltp/projects/connect-psql.md) instead of the SQL editor.

> [!NOTE]
>
> If the synced table uses [LTAP Direct Writes](https://docs.databricks.com/aws/en/oltp/projects/sync-tables.md#ltap-direct-writes), only B-tree indexes keep later full loads on LTAP Direct Writes. Other index types, such as GIN, make those loads use the standard sync path. The initial load isn't affected.

## <a id="ownership" />Ownership and permissions

A synced table is owned by the internal `databricks_writer_<dbid>` role, not by the user who created it, because the sync pipeline manages it (see [Postgres roles](https://docs.databricks.com/aws/en/oltp/projects/postgres-roles.md)). Owner-only commands, such as configuring row-level security, can't be run directly on a synced table.

> [!NOTE]
>
> This is an exception to the general Postgres rule, where objects you create yourself are owned by your Databricks identity if its login exists as a role in Postgres. The pipeline creates synced tables on your behalf.

### <a id="manage-creator-access" />Access for the user who creates a synced table

When you create a synced table, your Databricks identity is automatically granted access to use it. No `databricks_superuser` action is required. Your identity is granted the following privileges on the synced table:

| Object       | Privileges                     | Purpose                                           |
| ------------ | ------------------------------ | ------------------------------------------------- |
| Synced table | `SELECT`, `DELETE`, `TRUNCATE` | Read or clear the table                           |
| Schema       | `USAGE`, `CREATE`              | Use the schema and create objects such as indexes |

You aren't granted `INSERT` or `UPDATE`. The pipeline owns the table's data, so direct writes are overwritten on the next refresh. `DELETE` and `TRUNCATE` only clear the table. The next refresh repopulates the table from the source.

This access is derived from your Unity Catalog permissions on the synced table and is managed in Unity Catalog. To change it, update the user's Unity Catalog permissions. You can't `REVOKE` it from a Databricks identity directly in Postgres.

> [!NOTE]
>
> This access is tied to the identity that created the synced table. Changing the pipeline's **Run as** identity doesn't reassign it. To use a different owning identity, re-create the synced table under that identity.

### <a id="manage-access" />Manage synced table access

After a synced table is created, the `databricks_superuser` can read a synced table from Postgres. The `databricks_superuser` has `pg_read_all_data`, which lets this role read from all tables. It also has the `pg_write_all_data` privilege, which lets this role write to all tables. This means that a `databricks_superuser` can also write to a synced table in Postgres. Lakebase supports this writing behavior in case you need to make urgent changes in your target table. However, Databricks recommends making fixes in your source table instead.

* The `databricks_superuser` can also grant these privileges to other users:

  ```sql title="PostgreSQL"
  GRANT USAGE ON SCHEMA synced_table_schema TO user;
  ```

  ```sql title="PostgreSQL"
  GRANT SELECT ON synced_table_name TO user;
  ```

* The `databricks_superuser` can revoke these privileges:

  ```sql title="PostgreSQL"
  REVOKE USAGE ON SCHEMA synced_table_schema FROM user;
  ```

  ```sql title="PostgreSQL"
  REVOKE {SELECT | INSERT | UPDATE | DELETE} ON synced_table_name FROM user;
  ```

### <a id="manage-table-ops" />Manage synced table operations

The `databricks_superuser` can manage which users are authorized to perform specific operations on a synced table. The supported operations for synced tables are:

* `CREATE INDEX`
* `ALTER INDEX`
* `DROP INDEX`
* `DROP TABLE`

All other DDL operations are denied for synced tables.

To grant these privileges to additional users, the `databricks_superuser` must first create an extension on `databricks_auth`:

```sql title="PostgreSQL"
CREATE EXTENSION IF NOT EXISTS databricks_auth;
```

Then the `databricks_superuser` can add a user to manage a synced table:

```sql title="PostgreSQL"
SELECT databricks_synced_table_add_manager('"synced_table_schema"."synced_table"'::regclass, '[user]');
```

The `databricks_superuser` can remove a user from managing a synced table:

```sql title="PostgreSQL"
SELECT databricks_synced_table_remove_manager('[table]', '[user]');
```

The `databricks_superuser` can view all managers:

```sql title="PostgreSQL"
SELECT * FROM databricks_synced_table_managers;
```

## Delete a synced table

Deleting a synced table from Unity Catalog also drops the corresponding Postgres table.

### UI

In **Catalog**, find your synced table, click the ![Kebab menu icon.](https://docs.databricks.com/aws/en/images/product-icons/OverflowIcon.svg) menu, and select **Delete**.

### Python SDK

```python
from databricks.sdk import WorkspaceClient

w = WorkspaceClient()

w.postgres.delete_synced_table("synced_tables/my-catalog.sales.orders").wait()
```

### Java SDK

```java
import com.databricks.sdk.WorkspaceClient;

WorkspaceClient w = new WorkspaceClient();

w.postgres().deleteSyncedTable("synced_tables/my-catalog.sales.orders").waitForCompletion();
```

### curl

```bash
curl -X DELETE "https://your-workspace.cloud.databricks.com/api/2.0/postgres/synced_tables/my-catalog.sales.orders" \
  -H "Authorization: Bearer ${DATABRICKS_TOKEN}"
```

## <a id="catalog-integration" />Catalog integration

A synced table can appear in more than one catalog in Unity Catalog. This catalog duplication is expected when you create a synced table in a standard catalog and its destination Postgres database is also registered as a database catalog. In that case, the synced table appears under both catalogs.

## Sync to systems outside Databricks

For syncing data into non-Databricks systems, see [Partner Connect reverse ETL solutions](https://docs.databricks.com/aws/en/partner-connect/reverse-etl.md) such as Census or Hightouch.

## <a id="additional-resources" />Additional resources

* Learn how to [connect to your database](https://docs.databricks.com/aws/en/oltp/projects/connect.md)
* Register [a Lakebase database in Unity Catalog](https://docs.databricks.com/aws/en/oltp/projects/register-uc.md)
* Learn about [Unity Catalog](https://docs.databricks.com/aws/en/data-governance/unity-catalog/index.md)
