# ALTER LINK

The `ALTER LINK` command modifies an existing connection link.

This command modifies an existing link in place by updating its configuration and/or credentials clause, without recreating the link or dependent objects such as pipelines or external functions. Any pipelines (paused/stopped) or operations using this link continue to function with the updated connection details and their cursor positions are preserved.

## Syntax

```
ALTER LINK [database.]link_name
    <set_clause> [<set_clause>]

<set_clause>:
      SET CONFIG 'configuration_json'
    | SET CONFIG ::config_key = 'value'
    | SET CREDENTIALS 'credentials_json'
    | SET CREDENTIALS ::credential_key = 'value'
```

> **📝 Note**: Each `ALTER LINK` query can contain at most two `SET` clauses, provided that one is `SET CONFIG` and the other is `SET CREDENTIALS`.

## Arguments

* `database`: Name of the database that contains the link.
* `link_name`: Name of the existing link to modify.
* `SET CONFIG 'configuration_json'`: Specifies the link configuration in JSON format. The specified configuration replaces the existing `CONFIG` clause.
* `SET CONFIG ::config_key = 'value'`: Updates or adds a single top-level configuration parameter (key) in the configuration JSON. If the parameter exists, it is updated; otherwise, a new parameter is added to the configuration.
* `SET CREDENTIALS 'credentials_json'`: Specifies the link credentials in JSON format. The specified credentials replace the existing `CREDENTIALS` clause.
* `SET CREDENTIALS ::credential_key = 'value'`: Updates or adds a single top-level credential parameter (key) in the credentials JSON. If the parameter exists, it is updated; otherwise, a new parameter is added to the credentials JSON.

## Remarks

* An empty JSON object, such as `CONFIG '{}'`, clears the existing configuration.
* Refer to [Permissions Matrix](https://docs.singlestore.com/db/v9.1/reference/sql-reference/security-management-commands/permissions-matrix.md) for the required permissions.
* If a pipeline that uses the link is currently running, it must be paused or stopped before running the `ALTER LINK` command. Otherwise, the `ALTER LINK` command will return an error.
* After successfully running an `ALTER LINK` command, the `SHOW CREATE LINK` command returns the updated link definition.

## Examples

The examples use the following link:

```sql
CREATE LINK analytics_link AS S3
  CONFIG '{"disable_gunzip":false}'
  CREDENTIALS '{"aws_access_key_id":"initial_key_id",
                "aws_secret_access_key":"initial_secret"}';
```

**Note**: The output is formatted for readability.

* Add a configuration parameter:
  ```sql
  ALTER LINK analytics_link
    SET CONFIG ::region = "us-east-1";

  SHOW CREATE LINK analytics_link \G

  ```
  ```output

  Link Name: analytics_link
  Create Link: CREATE LINK `analytics_link` AS S3 
      CONFIG "{\"disable_gunzip\":false,\"region\":\"us-east-1\"}" 
      CREDENTIALS <CREDENTIALS REDACTED>
  ```
* Modify a single configuration parameter:
  ```sql
  ALTER LINK analytics_link
    SET CONFIG ::region = 'us-west-2';

  SHOW CREATE LINK analytics_link \G

  ```
  ```output

  Link Name: analytics_link
  Create Link: CREATE LINK `analytics_link` AS S3 
      CONFIG "{\"disable_gunzip\":false,\"region\":\"us-west-2\"}"
      CREDENTIALS <CREDENTIALS REDACTED>
  ```
* Replace the `CONFIG` JSON:
  ```sql
  ALTER LINK analytics_link
    SET CONFIG '{"region":"eu-central-1","disable_gunzip":true}';

  SHOW CREATE LINK analytics_link \G

  ```
  ```output

  Link Name: analytics_link
  Create Link: CREATE LINK `analytics_link` AS S3 
      CONFIG "{\"region\":\"eu-central-1\",\"disable_gunzip\":true}" 
      CREDENTIALS <CREDENTIALS REDACTED>
  ```
* Modify a single credential parameter:
  ```sql
  ALTER LINK analytics_link
    SET CREDENTIALS ::aws_access_key_id = 'rotated_key_id';

  SHOW CREATE LINK analytics_link \G

  ```
  ```output

  Link Name: analytics_link
  Create Link: CREATE LINK `analytics_link` AS S3 
      CONFIG "{\"region\":\"eu-central-1\",\"disable_gunzip\":true}" 
      CREDENTIALS <CREDENTIALS REDACTED>
  ```
* Replace the `CREDENTIALS` JSON:
  ```sql
  ALTER LINK analytics_link
    SET CREDENTIALS '{"aws_access_key_id":"final_key_id","aws_secret_access_key":"final_secret"}';

  SHOW CREATE LINK analytics_link \G

  ```
  ```output

  Link Name: analytics_link
  Create Link: CREATE LINK `analytics_link` AS S3 
      CONFIG "{\"region\":\"eu-central-1\",\"disable_gunzip\":true}" 
      CREDENTIALS <CREDENTIALS REDACTED>
  ```
* Modify the `CONFIG` and `CREDENTIAL` JSON in the same `ALTER LINK` query:
  ```sql
  ALTER LINK analytics_link
    SET CONFIG '{"region":"eu-central-1","disable_gunzip":true}'
    SET CREDENTIALS '{"aws_access_key_id":"final_key_id","aws_secret_access_key":"final_secret"}';

  SHOW CREATE LINK analytics_link \G

  ```
  ```output

  Link Name: analytics_link
  Create Link: CREATE LINK `analytics_link` AS S3 
      CONFIG "{\"region\":\"eu-central-1\",\"disable_gunzip\":true}" 
      CREDENTIALS <CREDENTIALS REDACTED>
  ```
  ```sql
  -- Using a combination of JSON and single-key updates

  ALTER LINK analytics_link
    SET CONFIG '{"region":"us-west-2","disable_gunzip":true}'
    SET CREDENTIALS ::aws_access_key_id = 'rotated_key_id';

  SHOW CREATE LINK analytics_link \G

  ```
  ```output

  Link Name: analytics_link
  Create Link: CREATE LINK `analytics_link` AS S3 
      CONFIG "{\"disable_gunzip\":true,\"region\":\"us-west-2\"}" 
      CREDENTIALS <CREDENTIALS REDACTED>
  ```

## Related Topics

* [CREATE LINK](https://docs.singlestore.com/db/v9.1/reference/sql-reference/security-management-commands/create-link.md)
* [DROP LINK](https://docs.singlestore.com/db/v9.1/reference/sql-reference/security-management-commands/drop-link.md)

***

Modified at: June 12, 2026

Source: [/db/v9.1/reference/sql-reference/security-management-commands/alter-link/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/security-management-commands/alter-link/)

(An index of the documentation is available at /llms.txt)
