Updated on 2023-10-23 GMT+08:00

ALTER SUBSCRIPTION

Function

ALTER SUBSCRIPTION alters the attributes of a subscription specified in CREATE SUBSCRIPTION.

Precautions

Only the owner of a subscription can execute ALTER SUBSCRIPTION. The new owner must be the system administrator.

Syntax

  • Update the connection information of a subscription.
    ALTER SUBSCRIPTION name CONNECTION 'conninfo'
  • Update the name of the publication on the publisher side.
    ALTER SUBSCRIPTION name SET PUBLICATION publication_name [, ...]
  • Enable a subscription.
    ALTER SUBSCRIPTION name ENABLE
  • Update the attributes defined in CREATE SUBSCRIPTION.
    ALTER SUBSCRIPTION name SET ( subscription_parameter [= value] [, ... ] )
  • Update the owner of a subscription.
    ALTER SUBSCRIPTION name OWNER TO new_owner
  • Change the name of a subscription.
    ALTER SUBSCRIPTION name RENAME TO new_name

Parameter Description

  • name

    Specifies the name of the subscription whose attributes are to be altered.

  • CONNECTION 'conninfo'

    Alters the connection attributes initially set by CREATE SUBSCRIPTION.

  • ENABLE (boolean)

    Specifies whether a subscription should be actively replicated, or whether it should be just set but not yet started. The default value is true.

  • SET ( subscription_parameter [= value] [, ... ] )
    Modifies the parameters set by CREATE SUBSCRIPTION. The allowed parameters are slot_name and synchronous_commit.
    • If enabled is set to false during subscription creation, slot_name is forcibly set to NONE, that is, null. In this case, the replication slot does not exist even if the value of slot_name is specified.
    • Change the value of enabled from false to true. When the subscription is enabled, the publication side is connected to create a replication slot. If you do not specify the value of slot_name, the default value (subscription name) is used.
    • If enabled is set to true, the subscription is in the normal state. In this case, slot_name cannot be left empty, but the name of the replication slot can be changed to a valid name.
  • new_owner

    Specifies the username of the new owner of a subscription.

  • new_name

    Specifies the new name of a subscription.

Examples

For details, see Examples.