---
title: Use standalone streaming tables
description: Create, refresh, and monitor standalone streaming tables with `CREATE OR REFRESH STREAMING TABLE`, including Auto Loader ingestion and AUTO CDC.
canonical_url: https://docs.databricks.com/aws/en/sql/mv-st/streaming
---

# Use standalone streaming tables

A standalone *streaming table* is a table registered to Unity Catalog with extra support for streaming or incremental data processing, defined outside of a Lakeflow pipeline. A pipeline is automatically created for each streaming table. You can use streaming tables for incremental data loading from Kafka and cloud object storage.

You can create and refresh standalone streaming tables from a Databricks SQL warehouse, or from a notebook running on serverless general compute. For details on the differences between the two compute options, see [Requirements for standalone pipelines](https://docs.databricks.com/aws/en/sql/mv-st/compute.md).

To create and refresh standalone streaming tables with Python from a notebook, see [Use Python with standalone pipelines](https://docs.databricks.com/aws/en/sql/mv-st/using-python.md).

> [!NOTE]
>
> To learn how to use Delta Lake tables as streaming sources and sinks, see [Delta Lake table streaming reads and writes](https://docs.databricks.com/aws/en/structured-streaming/delta-lake.md).

## <a id="requirements" />Requirements

For compute options, permissions, and other requirements for creating, refreshing, and querying standalone streaming tables, see [Requirements for standalone pipelines](https://docs.databricks.com/aws/en/sql/mv-st/compute.md).

## Create streaming tables

A streaming table is defined by a SQL query in Databricks SQL. When you create a streaming table, the data currently in the source tables is used to build the streaming table. After that, you refresh the table, usually on a schedule, to pull in any added data in the source tables to append to the streaming table.

When you create a streaming table, you are considered the owner of the table.

To create a streaming table from an existing table, use the [CREATE STREAMING TABLE statement](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-streaming-table.md), as in the following example:

```sql
CREATE OR REFRESH STREAMING TABLE sales
  SCHEDULE EVERY 1 hour
  AS SELECT product, price FROM STREAM raw_data;
```

In this case, the streaming table `sales` is created from specific columns of the `raw_data` table, with a schedule to refresh every hour. The query used must be a *streaming* query. Use the `STREAM` keyword to use streaming semantics to read from the source.

### Compute used for refresh

When you create a streaming table using the `CREATE OR REFRESH STREAMING TABLE` statement, the initial data refresh and population begin immediately. These operations do not consume Databricks SQL warehouse compute. Instead, streaming tables rely on serverless pipelines for both creation and refresh. A dedicated serverless pipeline is automatically created and managed by the system for each streaming table.

### <a id="load-files-with-auto-loader" />Load files with Auto Loader

To create a streaming table from files in a volume, you use Auto Loader. Use Auto Loader for most data ingestion tasks from cloud object storage. Auto Loader and pipelines are designed to incrementally and idempotently load ever-growing data as it arrives in cloud storage.

To use Auto Loader in Databricks SQL, use the `read_files` function. The following examples shows using Auto Loader to read a volume of JSON files into a streaming table:

```sql
CREATE OR REFRESH STREAMING TABLE sales
  SCHEDULE EVERY 1 hour
  AS SELECT * FROM STREAM read_files(
    "/Volumes/my_catalog/my_schema/my_volume/path/to/data",
    format => "json"
  );
```

To read data from cloud storage, you can also use Auto Loader:

```sql
CREATE OR REFRESH STREAMING TABLE sales
  SCHEDULE EVERY 1 hour
  AS SELECT *
  FROM STREAM read_files(
  's3://mybucket/analysis/*/*/*.json',
    format => "json"
  );
```

To learn about Auto Loader, see [What is Auto Loader?](https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/index.md). To learn more about using Auto Loader in SQL, with examples, see [Load data from object storage](https://docs.databricks.com/aws/en/ldp/developer/sql-dev.md#auto-loader-sql).

### <a id="streaming-ingestion-from-other-sources" />Streaming ingestion from other sources

For example of ingestion from other sources, including Kafka, see [Load data in pipelines](https://docs.databricks.com/aws/en/ldp/load.md).

### Apply change data capture (CDC) with Auto CDC flows

Use the `FLOW AUTO CDC` clause to process change data capture (CDC) records from a source into a streaming table. Previously, the `MERGE INTO` statement was commonly used for processing CDC records on Databricks. However, `MERGE INTO` can produce incorrect results because of out-of-sequence records or requires complex logic to re-order records. See [Change data capture and snapshots](https://docs.databricks.com/aws/en/data-engineering/what-is-cdc.md).

`AUTO CDC` simplifies CDC by automatically handling out-of-order records. You specify keys to identify records, a sequence column for ordering, and whether to store results as SCD type 1 (direct updates) or SCD type 2 (history tracking).

The following example creates a streaming table that applies CDC changes using SCD type 1:

```sql
CREATE OR REFRESH STREAMING TABLE target
  FLOW AUTO CDC
  FROM stream(cdc_data.users)
  KEYS (userId)
  SEQUENCE BY sequenceNum
  STORED AS SCD TYPE 1;
```

The following example uses SCD type 2 to retain a history of changes:

```sql
CREATE OR REFRESH STREAMING TABLE target
  FLOW AUTO CDC
  FROM stream(cdc_data.users)
  KEYS (userId)
  APPLY AS DELETE WHEN operation = "DELETE"
  SEQUENCE BY sequenceNum
  COLUMNS * EXCEPT (operation, sequenceNum)
  STORED AS SCD TYPE 2;
```

For full details on Auto CDC options and behavior, see [The AUTO CDC APIs: Simplify change data capture with pipelines](https://docs.databricks.com/aws/en/ldp/cdc.md). For the complete syntax reference, see [CREATE STREAMING TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-streaming-table.md).

### Apply selective batch replacement with REPLACE WHERE flows

Use the `FLOW REPLACE WHERE` clause to recompute and overwrite a targeted subset of a streaming table without reprocessing your entire table history. `REPLACE WHERE` flows are well-suited for incremental batch processing of joins and aggregations, late-arriving data, upstream reprocessing, schema evolution, and backfills.

For full details on `REPLACE WHERE` flows, including requirements, predicate overrides, and incremental refresh, see [REPLACE WHERE flows for standalone streaming tables](https://docs.databricks.com/aws/en/sql/mv-st/flows-replace-where.md).

### <a id="replace-using" />Apply partial snapshot replacement with REPLACE USING flows

> [!NOTE]
> **Beta**
>
> REPLACE USING flows are in [Beta](https://docs.databricks.com/aws/en/release-notes/release-types.md).

Use the `FLOW REPLACE USING` clause to keep a streaming table in sync with a stream of partial snapshots. On each update, a REPLACE USING flow replaces all rows that match the specified key columns and leaves all other rows unchanged. A `SEQUENCE BY` column orders the updates so the highest sequence for a key always wins, even when updates arrive out of order. For example:

```sql
CREATE OR REFRESH STREAMING TABLE payments_current
FLOW REPLACE USING (payment_id) SEQUENCE BY payment_date BY NAME
SELECT payment_id, booking_id, status, payment_date
FROM STREAM(samples.wanderbricks.payments);
```

`BY NAME` is required. It matches columns by name rather than position.

REPLACE USING behaves the same for standalone streaming tables as it does in Lakeflow pipelines. For how it works, sequencing, expectations, limitations, and examples, see [Partial snapshot replacement with REPLACE USING flows](https://docs.databricks.com/aws/en/ldp/flows-replace-using.md). The following differences apply to standalone streaming tables:

* **Define the flow in SQL.** Author the REPLACE USING flow with the inline SQL `FLOW REPLACE USING` clause on `CREATE OR REFRESH STREAMING TABLE`. The standalone `CREATE FLOW` statement is a Lakeflow pipeline construct and isn't used for standalone streaming tables.
* **Compute is managed for you.** Standalone streaming tables run on system-managed serverless pipelines and require Databricks Runtime 18.2 and above. You don't choose between classic and serverless compute.

### Ingest new data only

By default, the `read_files` function reads all existing data in the source folder during table creation, and then processes newly arriving records with each refresh.

To avoid ingesting data that already exists in the source folder at the time of table creation, set the `includeExistingFiles` option to `false`. This means that only data that arrives in the folder after table creation is processed. For example:

```sql
CREATE OR REFRESH STREAMING TABLE sales
  SCHEDULE EVERY 1 hour
  AS SELECT *
  FROM STREAM read_files(
    '/path/to/files',
    includeExistingFiles => false
  );
```

### <a id="set-runtime" />Runtime version

Streaming tables always run on the latest Databricks SQL runtime version. The `pipelines.channel` table property, previously used to select a `preview` or `current` runtime channel, is no longer supported and has no effect. If an existing definition includes this property, it is safely ignored and you do not need to remove it.

### <a id="hide-sensitive" />Hide sensitive data

You can use streaming tables to hide sensitive data from users accessing the table. One approach is to define the query so that it excludes sensitive columns or rows entirely. Alternatively, you can apply column masks or row filters based on the permissions of the querying user. For example, you might hide the `tax_id` column for users who are not in the group `HumanResourcesDept`. To do this, use the `ROW FILTER` and `MASK` syntax during the creation of the streaming table. For more information, see [Row filters and column masks](https://docs.databricks.com/aws/en/data-governance/unity-catalog/filters-and-masks/index.md).

## <a id="refresh" />Refresh a streaming table

Streaming tables automatically create and use serverless pipelines to process refresh operations. The refresh is managed by the pipeline and the update is monitored by the Databricks SQL warehouse used to create the streaming table. Streaming tables can be updated using a pipeline that runs on a [schedule](https://docs.databricks.com/aws/en/sql/mv-st/schedule-refreshes.md).

Even if you have a scheduled refresh, you can call a manual refresh at any time. Refreshes are handled by the same pipeline that was automatically created along with the streaming table.

To refresh a streaming table:

```sql
REFRESH STREAMING TABLE sales;
```

You can check the status of the latest refresh with [DESCRIBE TABLE EXTENDED](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-describe-table.md).

> [!NOTE]
>
> You might need to refresh your streaming table before using [time travel](https://docs.databricks.com/aws/en/tables/history.md#time-travel) queries.

To learn how to schedule a refresh, see [Schedule refreshes](https://docs.databricks.com/aws/en/sql/mv-st/schedule-refreshes.md). Scheduled refreshes can have update [notifications](https://docs.databricks.com/aws/en/sql/mv-st/schedule-refreshes.md#notifications), and you can set the [performance mode](https://docs.databricks.com/aws/en/sql/mv-st/schedule-refreshes.md#performance-mode) for the refresh.

### How refresh works

A streaming table refresh only evaluates new rows that have arrived after the last update, and appends only the new data.

Each refresh uses the current definition of the streaming table to process this new data. Modifying a streaming table definition does not automatically recalculate existing data. If a modification is incompatible with existing data (for example, changing a data type), the next refresh fails with an error.

The following examples explain how changes to a streaming table definition affect refresh behavior:

* Removing a filter does not reprocess previously filtered rows.
* Changing column projections does not affect how existing data was processed.
* Joins with static snapshots use the snapshot state at the time of the initial processing. Late-arriving data that would have matched with the updated snapshot is ignored. This can lead to facts being dropped if dimensions are late.
* Modifying the CAST of an existing column results in an error.

If your data changes in a way that cannot be supported in the existing streaming table, you can perform a full refresh.

### Fully refresh a streaming table

Full refreshes re-process all data available in the source with the latest definition. It is not recommended to call full refreshes on sources that don't keep the entire history of the data or have short retention periods, such as Kafka, because the full refresh truncates the existing data. You might not be able to recover old data if the data is no longer available in the source.

For example:

```sql
REFRESH STREAMING TABLE sales FULL;
```

### <a id="schedule" />Schedule and monitor refreshes

You can refresh a streaming table automatically on a schedule or when upstream data changes, and you can configure refresh timeouts, notifications, and performance modes. See [Schedule refreshes](https://docs.databricks.com/aws/en/sql/mv-st/schedule-refreshes.md).

The system managed jobs and pipelines that run scheduled refreshes appear on the **System Managed** tab of the **Jobs & Pipelines** list (Beta). See [View system managed jobs and pipelines in the Jobs & Pipelines list](https://docs.databricks.com/aws/en/sql/mv-st/schedule-refreshes.md#system-managed-list).

## <a id="control-access" />Control access to streaming tables

Streaming tables support rich access controls to support data-sharing while avoiding exposing potentially private data. A streaming table owner or a user with the `MANAGE` privilege can grant `SELECT` privileges to other users. Users with `SELECT` access to the streaming table do not require `SELECT` access to the tables referenced by the streaming table. This access control enables data sharing while controlling access to the underlying data.

You can also modify the owner of a streaming table.

### Grant privileges to a streaming table

To grant access to a streaming table, use the [GRANT statement](https://docs.databricks.com/aws/en/sql/language-manual/security-grant.md):

```sql
GRANT <privilege_type> ON <st_name> TO <principal>;
```

For example, to let a user query a streaming table, grant the `SELECT` privilege:

```sql
CREATE OR REFRESH STREAMING TABLE st_name AS SELECT * FROM STREAM source_table;

-- Grant read-only access:
GRANT SELECT ON st_name TO read_only_user;
```

To refresh a streaming table, a user must be the owner or have both the `SELECT` and `MANAGE` privileges on the streaming table. Refreshes run using the owner's permissions. `MANAGE` also lets the user manage privileges on, transfer ownership of, and drop the streaming table. See [MANAGE](https://docs.databricks.com/aws/en/data-governance/unity-catalog/access-control/privileges-reference.md#manage).

For more information about granting privileges on Unity Catalog securable objects, see [Unity Catalog privileges reference](https://docs.databricks.com/aws/en/data-governance/unity-catalog/access-control/privileges-reference.md).

### Revoke privileges from a streaming table

To revoke access from a streaming table, use the [REVOKE statement](https://docs.databricks.com/aws/en/sql/language-manual/security-revoke.md):

```sql
REVOKE privilege_type ON <st_name> FROM principal;
```

When `SELECT` privileges on a source table are revoked from the streaming table owner or any other user who has been granted `MANAGE` or `SELECT` privileges on the streaming table, or the source table is dropped, the streaming table owner or user granted access is still able to query the streaming table. However, the following behavior occurs:

* The streaming table owner or others who have lost access to a streaming table can no longer `REFRESH` that streaming table, and the streaming table becomes stale over time.
* If automated with a schedule, the next scheduled `REFRESH` fails or is not run.

The following example revokes the `SELECT` privilege from `read_only_user`:

```sql
REVOKE SELECT ON st_name FROM read_only_user;
```

### <a id="change-owner" />Change the owner of a streaming table

A user with `MANAGE` permissions on a standalone streaming table can set a new owner through the Catalog Explorer. The new owner can be themselves or a service principal on which they have the **Service Principal User** role.

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

2. Select the streaming table that you want to update.

3. In the right sidebar, under **About this streaming table**, find the **Owner**, and click ![Pencil icon.](https://docs.databricks.com/aws/en/images/product-icons/PencilIcon.svg) edit.

   > [!NOTE]
   >
   > If you get a message that tells you to update the owner by changing the **Run as** user in pipeline settings, then the streaming table is defined in a Lakeflow pipeline, not as a standalone table. The message includes a link to the pipeline settings, where you can change the **Run as** user.

4. Select a new owner for the streaming table.

   Owners automatically have `MANAGE` and `SELECT` privileges on streaming tables that they own. If you are setting a service principal as the owner for a streaming table that you own, and you do not explicitly have `SELECT` or `MANAGE` privileges on the streaming table, then this change would cause you to lose all access to the streaming table. In this case, you are prompted to explicitly provide those privileges.

   Select both **Grant MANAGE** and **Grant SELECT** privileges to provide those on **Save**.

5. Click **Save** to change the owner.

The owner of the streaming table is updated. All future updates are run using the new owner's identity.

### When the owner loses privileges to source tables

If you change the owner, and the new owner does not have access to the source tables (or `SELECT` privileges are revoked on the underlying source tables), users can still query the streaming table. However:

* They cannot `REFRESH` the streaming table.
* The next scheduled refresh of the streaming table fails.

Losing access to the source data prevents updates, but doesn't immediately invalidate the existing streaming table from being read.

## <a id="delete-records-st" />Permanently delete records from a streaming table

> [!NOTE]
> **Preview**
>
> Support for the `REORG` statement with streaming tables is in [Public Preview](https://docs.databricks.com/aws/en/release-notes/release-types.md).

> [!NOTE]
>
> * Using a `REORG` statement with a streaming table requires Databricks Runtime 15.4 and above.
> * Although you can use the `REORG` statement with any streaming table, it's only required when deleting records from a streaming table with [deletion vectors](https://docs.databricks.com/aws/en/tables/features/deletion-vectors.md) enabled. The command has no effect when used with a streaming table without deletion vectors enabled.

To physically delete records from the underlying storage for a streaming table with deletion vectors enabled, such as for GDPR compliance, additional steps must be taken to ensure that a [VACUUM](https://docs.databricks.com/aws/en/sql/language-manual/delta-vacuum.md) operation runs on the streaming table's data.

To physically delete records from underlying storage:

1. Update records or delete records from the streaming table.
2. Run a `REORG` statement against the streaming table, specifying the `APPLY (PURGE)` parameter. For example `REORG TABLE <streaming-table-name> APPLY (PURGE);`.
3. Wait for the streaming table's data retention period to pass. The default data retention period is seven days, but it can be configured with the `delta.deletedFileRetentionDuration` table property. See [Configure data retention for time travel queries](https://docs.databricks.com/aws/en/tables/history.md#data-retention).
4. `REFRESH` the streaming table. See [Refresh a streaming table](https://docs.databricks.com/aws/en/sql/mv-st/streaming.md#refresh). Within 24 hours of the `REFRESH` operation, pipeline maintenance tasks, including the `VACUUM` operation which is required to ensure records are permanently deleted, are run automatically.

## Monitor runs using query history

You can use the query history page to access query details and query profiles that can help you identify poorly performing queries and bottlenecks in the pipeline used to run your streaming table updates. For an overview of the kind of information available in query histories and query profiles, see [Query history](https://docs.databricks.com/aws/en/sql/user/queries/query-history.md) and [Query profile](https://docs.databricks.com/aws/en/sql/user/queries/query-profile.md).

All statements related to streaming tables appear in the query history. You can use the **Statement** drop-down filter to select any command and inspect the related queries. All `CREATE` statements are followed by a `REFRESH` statement that executes asynchronously on a pipeline. The `REFRESH` statements typically include detailed query plans that provide insights into optimizing performance.

To access `REFRESH` statements in the query history UI, use the following steps:

1. Click ![History icon.](https://docs.databricks.com/aws/en/images/product-icons/HistoryIcon.svg) in the left sidebar to open the **Query History** UI.
2. Select the **REFRESH** checkbox from the **Statement** drop-down filter.
3. Click the name of the query statement to view summary details like the duration of the query and aggregated metrics.
4. Click **See query profile** to open the query profile. See [Query profile](https://docs.databricks.com/aws/en/sql/user/queries/query-profile.md) for details about navigating the query profile.
5. Optionally, you can use the links in the **Query Source** section to open the related query or pipeline.

You can also access query details using links in the SQL editor or from a notebook attached to a SQL warehouse.

## <a id="external-access" />Access streaming tables from external clients

To access streaming tables from external Delta Lake or Iceberg clients that don't support open APIs, you can use [Compatibility Mode](https://docs.databricks.com/aws/en/external-access/compatibility-mode.md). Compatibility Mode creates a read-only version of your streaming table that can be accessed by any Delta Lake or Iceberg client.

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

* [Spark Declarative Pipelines on Lakeflow](https://docs.databricks.com/aws/en/ldp/index.md)
* [`read_files` table-valued function](https://docs.databricks.com/aws/en/sql/language-manual/functions/read_files.md)
* [`read_kafka` table-valued function](https://docs.databricks.com/aws/en/sql/language-manual/functions/read_kafka.md)
* [CREATE STREAMING TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-streaming-table.md)
* [ALTER STREAMING TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-streaming-table.md)
* [Use standalone materialized views](https://docs.databricks.com/aws/en/sql/mv-st/materialized.md)
* [The AUTO CDC APIs: Simplify change data capture with pipelines](https://docs.databricks.com/aws/en/ldp/cdc.md)
