---
metadata:
  - name: generator
    content: Diplodoc Platform v5.71.0
alternate:
  - https://ydb.tech/docs/en/yql/reference/syntax/alter-async-replication.md?version=v26.3
  - https://ydb.tech/docs/ru/yql/reference/syntax/alter-async-replication.md?version=v26.3
  - href: https://ydb.tech/docs/en/yql/reference/syntax/alter-async-replication.md?version=v26.3
    type: text/markdown
    title: Markdown version
  - href: https://ydb.tech/docs/en/llms.txt?revision=962422e645f28cc9d83f45f9bb5846da6ee2ca46&version=v26.3
    rel: describedby
sourcePath: en/core/yql/reference/syntax/alter-async-replication.md
---
> **Documentation capabilities:** Search, read sources, and browse this documentation: [agent guide](https://ydb.tech/docs/docs-api/agent/overview?project=ydb-platform--ydb&lang=en&version=v26.3).

> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt?revision=962422e645f28cc9d83f45f9bb5846da6ee2ca46&version=v26.3

# ALTER ASYNC REPLICATION

The `ALTER ASYNC REPLICATION` statement modifies the status and parameters of an [asynchronous replication instance](https://ydb.tech/docs/en/concepts/async-replication.md?version=v26.3).

## Syntax {#syntax}

```yql
ALTER ASYNC REPLICATION <name> SET (option = value [, ...])
```

### Parameters {#params}

* `name` — a name of the asynchronous replication instance.
* `SET (option = value [, ...])` — asynchronous replication parameters:

    * `STATE`: the state of asynchronous replication. Valid values are:

        * `PAUSED`: pause the application of changes. Changefeeds in the source continue accumulating records according to the [availability policy](https://ydb.tech/docs/en/concepts/async-replication.md?version=v26.3#availability-period) set by `AVAILABILITY_PERIOD`. Replica objects already attached remain read-only.
        * `STANDBY`: start or resume change data replication. For replication created with `INITIAL_SCAN = FALSE`, attaches previously restored target tables. Before starting replication, finish importing all tables as described in the [initial synchronization guide](https://ydb.tech/docs/en/devops/async-replication-initial-sync.md?version=v26.3).
        * `DONE`: [complete the asynchronous replication process](https://ydb.tech/docs/en/concepts/async-replication.md?version=v26.3#done). For forced completion, also specify `FAILOVER_MODE = 'FORCE'`.

    * `FAILOVER_MODE`: the replication completion mode. Applies only with `STATE = 'DONE'`. This parameter is not required for `PAUSED` or `STANDBY`. Valid values are:

        * `FORCE` — forced failover.

* Authentication settings for the source database (one of the following):

  <!-- source: en/yql/reference/syntax/_includes/async_replication_authentification.md -->
  * Using a [token](https://ydb.tech/docs/en/recipes/ydb-sdk/auth-access-token.md?version=v26.3):

      * `TOKEN_SECRET_PATH` — the [secret](https://ydb.tech/docs/en/concepts/datamodel/secrets.md?version=v26.3) that contains the token.

  * Using a [username and password](https://ydb.tech/docs/en/recipes/ydb-sdk/auth-static.md?version=v26.3):

      * `USER` — the username.
      * `PASSWORD_SECRET_PATH` — the [secret](https://ydb.tech/docs/en/concepts/datamodel/secrets.md?version=v26.3) that contains the password.

  * Using a [service agent](https://yandex.cloud/ru/docs/iam/concepts/service-control?utm_referrer=about%3Ablank#service-agent):

      * `SERVICE_ACCOUNT_ID` — the identificator of the service account.
      * `INITIAL_TOKEN_SECRET_PATH` — the [secret](https://ydb.tech/docs/en/concepts/datamodel/secrets.md?version=v26.3) that contains the account's token. It is used for initial authentication.
  <!-- endsource: en/yql/reference/syntax/_includes/async_replication_authentification.md -->

## Examples {#examples}

The following statement starts replication after [importing the initial data](https://ydb.tech/docs/en/devops/async-replication-initial-sync.md?version=v26.3#import):

```yql
ALTER ASYNC REPLICATION my_replication SET (STATE = 'STANDBY');
```

The following statement pauses the application of changes:

```yql
ALTER ASYNC REPLICATION my_replication SET (STATE = 'PAUSED');
```

To resume replication, use `STATE = 'STANDBY'`. With a finite `AVAILABILITY_PERIOD`, account for the age of messages already accumulated, the pause, and subsequent processing time: pausing does not suspend the availability period. With `'UNLIMITED'`, unacknowledged changes are retained until processed; monitor free space in the source.

The following statement forces the asynchronous replication process to complete:

```yql
ALTER ASYNC REPLICATION my_replication SET (STATE = "DONE", FAILOVER_MODE = "FORCE");
```

The following query changes the secret:

```yql
ALTER ASYNC REPLICATION my_replication SET (TOKEN_SECRET_PATH = "my_token");
```

## See also

* [CREATE ASYNC REPLICATION](https://ydb.tech/docs/en/yql/reference/syntax/create-async-replication.md?version=v26.3)
* [DROP ASYNC REPLICATION](https://ydb.tech/docs/en/yql/reference/syntax/drop-async-replication.md?version=v26.3)
