CREATE SUBSCRIPTION
Function
CREATE SUBSCRIPTION adds a new subscription (SUBSCRIPTION) to the current database.
A subscription is the process by which a database instance (called the subscriber) receives data changes from another database instance (called the publisher). The subscriber achieves data synchronization and distribution by subscribing to data changes from the publisher.
This syntax has been deprecated in clusters of version 9.1.1.100 or later. An error "SUBSCRIPTION is not yet supported" will be reported when the syntax is executed.
Precautions
- Only system administrators can create subscriptions.
- The name of a newly created subscription must not be the same as any existing subscription name in the current database.
Syntax
1 2 3 4 | CREATE SUBSCRIPTION name CONNECTION 'conninfo' PUBLICATION publication_name [, ...] [ WITH ( subscription_parameter [= value] [, ... ] ) ] |
Parameter Description
| Parameter | Description | Value Range |
|---|---|---|
| name | Specifies the name of a subscription. | A string, which must comply with the naming convention. For details, see Identifier Naming Conventions. |
| conninfo | Specifies the string for connecting to the publication side.
| Example: host=1.1.1.1,2.2.2.2 port=10000,20000 dbname=postgres user=repusr1 password=password |
| publication_name | Specifies the name of the publication you want to subscribe to on the publication side. A subscription corresponds to multiple publications. | An existing publication name. |
| WITH ( subscription_parameter [= value] [, ... ] ) | Specifies the optional parameters for a subscription.
| - |
Examples
For details about the sample data published by the database, see Examples.
- Create a subscription to subscribe to the publication of the upstream database.
CREATE SUBSCRIPTION sub_demo CONNECTION 'host=10.***.*.** port=10000 user=u_admin dbname=testdb password=********' PUBLICATION pub_sales_only; - Subscribe to multiple publications.
CREATE SUBSCRIPTION sub_demo_1 CONNECTION 'host=10.***.*.** port=10000 user=u_admin dbname=testdb password=********' PUBLICATION pub_sales_only,pub_sales_all_ops; - Subscribe to all tables (the upstream publication must contain ALL TABLES IN SCHEMA).
CREATE SUBSCRIPTION sub_demo_1 CONNECTION 'host=10.***.*.** port=10000 user=u_admin dbname=testdb password=********' PUBLICATION pub_all_tables;
Helpful Links
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot