{"Entry":{"collection":"sql","key":"create-subscription","name":"CREATE SUBSCRIPTION","aliases":["createsubscription"],"metadata":{"aliases":["createsubscription"],"changed_in":["19"],"changes":[{"from":"9.6","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"10"},{"from":"10","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"11"},{"from":"11","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes"],"removed":[]},"status":"changed","synopsis":null,"to":"12"},{"from":"13","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes"],"removed":[]},"status":"changed","synopsis":null,"to":"14"},{"from":"14","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes"],"removed":[]},"status":"changed","synopsis":null,"to":"15"},{"from":"15","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes"],"removed":[]},"status":"changed","synopsis":null,"to":"16"},{"from":"16","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes"],"removed":[]},"status":"changed","synopsis":null,"to":"17"},{"from":"17","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","notes"],"removed":[]},"status":"changed","synopsis":null,"to":"18"},{"from":"18","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","notes"],"removed":[]},"status":"changed","synopsis":{"added":["{ SERVER server_name | CONNECTION 'conninfo' }"],"removed":[]},"to":"19"},{"from":"19","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"20"}],"content_hash":"261e8dab62f664d76d940430f64a9f423990856fb3c4c0fae640e8e7852353b3","editorial":{},"first_version":"10","group":"replication","imported_at":"2026-09-30T17:43:38.928555+08:00","last_version":"20","name":"CREATE SUBSCRIPTION","object":"SUBSCRIPTION","position":10003,"present_in":["10","11","12","13","14","15","16","17","18","19","20"],"purpose":"define a new subscription","purpose_zh":"","related":["alter-subscription","drop-subscription","create-publication","alter-publication"],"slug":"create-subscription","source_rev":"a709ab85","synopsis":"CREATE SUBSCRIPTION subscription_name\n{ SERVER server_name | CONNECTION 'conninfo' }\nPUBLICATION publication_name [, ...]\n[ WITH ( subscription_parameter [= value] [, ... ] ) ]","verb":"CREATE"}},"Definition":{"Collection":"sql","Key":"create-subscription","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"create-subscription","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-CREATESUBSCRIPTION","file":"sql-createsubscription.html","lang":"en","name":"CREATE SUBSCRIPTION","purpose":"define a new subscription","purpose_zh":"","related":["alter-subscription","drop-subscription","create-publication","alter-publication"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE SUBSCRIPTION\u003c/code\u003e adds a new logical-replication subscription. The user that creates a subscription becomes the owner of the subscription. The subscription name must be distinct from the name of any existing subscription in the current database.\u003c/p\u003e\u003cp\u003eA subscription represents a replication connection to the publisher. Hence, in addition to adding definitions in the local catalogs, this command normally creates a replication slot on the publisher.\u003c/p\u003e\u003cp\u003eA logical replication worker will be started to replicate data for the new subscription at the commit of the transaction where this command is run, unless the subscription is initially disabled.\u003c/p\u003e\u003cp\u003eTo be able to create a subscription, you must have the privileges of the \u003ccode class=\"literal\"\u003epg_create_subscription\u003c/code\u003e role, as well as \u003ccode class=\"literal\"\u003eCREATE\u003c/code\u003e privileges on the current database.\u003c/p\u003e\u003cp\u003eAdditional information about subscriptions and logical replication as a whole is available at \u003ca href=\"/docs/18/logical-replication-subscription.html\" title=\"29.2. Subscription\"\u003eSection 29.2\u003c/a\u003e and \u003ca href=\"/docs/18/logical-replication.html\" title=\"Chapter 29. Logical Replication\"\u003eChapter 29\u003c/a\u003e.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esubscription_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of the new subscription.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eCONNECTION '\u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e'\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e connection string defining how to connect to the publisher database. For details see \u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003eSection 32.1.1\u003c/a\u003e.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ePUBLICATION \u003cem class=\"replaceable\"\u003e\u003ccode\u003epublication_name\u003c/code\u003e\u003c/em\u003e [, ...]\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eNames of the publications on the publisher to subscribe to.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eWITH ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003esubscription_parameter\u003c/code\u003e\u003c/em\u003e [= \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e] [, ... ] )\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThis clause specifies optional parameters for a subscription.\u003c/p\u003e\u003cp\u003eThe following parameters control what happens during subscription creation:\u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003econnect\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eSpecifies whether the \u003ccode class=\"command\"\u003eCREATE SUBSCRIPTION\u003c/code\u003e command should connect to the publisher at all. The default is \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e. Setting this to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e will force the values of \u003ccode class=\"literal\"\u003ecreate_slot\u003c/code\u003e, \u003ccode class=\"literal\"\u003eenabled\u003c/code\u003e and \u003ccode class=\"literal\"\u003ecopy_data\u003c/code\u003e to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e. (You cannot combine setting \u003ccode class=\"literal\"\u003econnect\u003c/code\u003e to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e with setting \u003ccode class=\"literal\"\u003ecreate_slot\u003c/code\u003e, \u003ccode class=\"literal\"\u003eenabled\u003c/code\u003e, or \u003ccode class=\"literal\"\u003ecopy_data\u003c/code\u003e to \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e.)\u003c/p\u003e\u003cp\u003eSince no connection is made when this option is \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e, no tables are subscribed. To initiate replication, you must manually create the replication slot, enable the failover if required, enable the subscription, and refresh the subscription. See \u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" title=\"29.2.3. Examples: Deferred Replication Slot Creation\"\u003eSection 29.2.3\u003c/a\u003e for examples.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecreate_slot\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eSpecifies whether the command should create the replication slot on the publisher. The default is \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e.\u003c/p\u003e\u003cp\u003eIf set to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e, you are responsible for creating the publisher's slot in some other way. See \u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" title=\"29.2.3. Examples: Deferred Replication Slot Creation\"\u003eSection 29.2.3\u003c/a\u003e for examples.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eenabled\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eSpecifies whether the subscription should be actively replicating or whether it should just be set up but not started yet. The default is \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eslot_name\u003c/code\u003e (\u003ccode class=\"type\"\u003estring\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eName of the publisher's replication slot to use. The default is to use the name of the subscription for the slot name.\u003c/p\u003e\u003cp\u003eSetting \u003ccode class=\"literal\"\u003eslot_name\u003c/code\u003e to \u003ccode class=\"literal\"\u003eNONE\u003c/code\u003e means there will be no replication slot associated with the subscription. Such subscriptions must also have both \u003ccode class=\"literal\"\u003eenabled\u003c/code\u003e and \u003ccode class=\"literal\"\u003ecreate_slot\u003c/code\u003e set to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e. Use this when you will be creating the replication slot later manually. See \u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" title=\"29.2.3. Examples: Deferred Replication Slot Creation\"\u003eSection 29.2.3\u003c/a\u003e for examples.\u003c/p\u003e\u003cp\u003eWhen setting \u003ccode class=\"literal\"\u003eslot_name\u003c/code\u003e to a valid name and \u003ccode class=\"literal\"\u003ecreate_slot\u003c/code\u003e to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e, the \u003ccode class=\"literal\"\u003efailover\u003c/code\u003e property value of the named slot may differ from the counterpart \u003ccode class=\"literal\"\u003efailover\u003c/code\u003e parameter specified in the subscription. Always ensure the slot property \u003ccode class=\"literal\"\u003efailover\u003c/code\u003e matches the counterpart parameter of the subscription and vice versa. Otherwise, the slot on the publisher may behave differently from what these subscription options say: for example, the slot on the publisher could either be synced to the standbys even when the subscription's \u003ccode class=\"literal\"\u003efailover\u003c/code\u003e option is disabled or could be disabled for sync even when the subscription's \u003ccode class=\"literal\"\u003efailover\u003c/code\u003e option is enabled.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003eThe following parameters control the subscription's replication behavior after it has been created:\u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ebinary\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eSpecifies whether the subscription will request the publisher to send the data in binary format (as opposed to text). The default is \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e. Any initial table synchronization copy (see \u003ccode class=\"literal\"\u003ecopy_data\u003c/code\u003e) also uses the same format. Binary format can be faster than the text format, but it is less portable across machine architectures and \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e versions. Binary format is very data type specific; for example, it will not allow copying from a \u003ccode class=\"type\"\u003esmallint\u003c/code\u003e column to an \u003ccode class=\"type\"\u003einteger\u003c/code\u003e column, even though that would work fine in text format. Even when this option is enabled, only data types having binary send and receive functions will be transferred in binary. Note that the initial synchronization requires all data types to have binary send and receive functions, otherwise the synchronization will fail (see \u003ca href=\"/docs/18/sql-createtype.html\" title=\"CREATE TYPE\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE TYPE\u003c/span\u003e\u003c/a\u003e for more about send/receive functions).\u003c/p\u003e\u003cp\u003eWhen doing cross-version replication, it could be that the publisher has a binary send function for some data type, but the subscriber lacks a binary receive function for that type. In such a case, data transfer will fail, and the \u003ccode class=\"literal\"\u003ebinary\u003c/code\u003e option cannot be used.\u003c/p\u003e\u003cp\u003eIf the publisher is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e version before 16, then any initial table synchronization will use text format even if \u003ccode class=\"literal\"\u003ebinary = true\u003c/code\u003e.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecopy_data\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eSpecifies whether to copy pre-existing data in the publications that are being subscribed to when the replication starts. The default is \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e.\u003c/p\u003e\u003cp\u003eIf the publications contain \u003ccode class=\"literal\"\u003eWHERE\u003c/code\u003e clauses, it will affect what data is copied. Refer to the \u003ca href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-NOTES\" title=\"Notes\"\u003eNotes\u003c/a\u003e for details.\u003c/p\u003e\u003cp\u003eSee \u003ca href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-NOTES\" title=\"Notes\"\u003eNotes\u003c/a\u003e for details of how \u003ccode class=\"literal\"\u003ecopy_data = true\u003c/code\u003e can interact with the \u003ccode class=\"literal\"\u003eorigin\u003c/code\u003e parameter.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003estreaming\u003c/code\u003e (\u003ccode class=\"type\"\u003eenum\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eSpecifies whether to enable streaming of in-progress transactions for this subscription. The default value is \u003ccode class=\"literal\"\u003eparallel\u003c/code\u003e, meaning incoming changes are directly applied via one of the parallel apply workers, if available. If no parallel apply worker is free to handle streaming transactions then the changes are written to temporary files and applied after the transaction is committed. Note that if an error happens in a parallel apply worker, the finish LSN of the remote transaction might not be reported in the server log.\u003c/p\u003e\u003cdiv class=\"caution\"\u003e\u003ch3\u003eCaution\u003c/h3\u003e\u003cp\u003eThere is a risk of deadlock when the schemas of the publisher and subscriber differ, although such cases are rare. The apply worker is equipped to retry these transactions automatically.\u003c/p\u003e\u003c/div\u003e\u003cp\u003eIf set to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, the incoming changes are written to temporary files and then applied only after the transaction is committed on the publisher and received by the subscriber.\u003c/p\u003e\u003cp\u003eIf set to \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e, all transactions are fully decoded on the publisher and only then sent to the subscriber as a whole.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003esynchronous_commit\u003c/code\u003e (\u003ccode class=\"type\"\u003eenum\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe value of this parameter overrides the \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT\"\u003esynchronous_commit\u003c/a\u003e setting within this subscription's apply worker processes. The default value is \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e.\u003c/p\u003e\u003cp\u003eIt is safe to use \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e for logical replication: If the subscriber loses transactions because of missing synchronization, the data will be sent again from the publisher.\u003c/p\u003e\u003cp\u003eA different setting might be appropriate when doing synchronous logical replication. The logical replication workers report the positions of writes and flushes to the publisher, and when using synchronous replication, the publisher will wait for the actual flush. This means that setting \u003ccode class=\"literal\"\u003esynchronous_commit\u003c/code\u003e for the subscriber to \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e when the subscription is used for synchronous replication might increase the latency for \u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e on the publisher. In this scenario, it can be advantageous to set \u003ccode class=\"literal\"\u003esynchronous_commit\u003c/code\u003e to \u003ccode class=\"literal\"\u003elocal\u003c/code\u003e or higher.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etwo_phase\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eSpecifies whether two-phase commit is enabled for this subscription. The default is \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e.\u003c/p\u003e\u003cp\u003eWhen two-phase commit is enabled, prepared transactions are sent to the subscriber at the time of \u003ccode class=\"command\"\u003ePREPARE TRANSACTION\u003c/code\u003e, and are processed as two-phase transactions on the subscriber too. Otherwise, prepared transactions are sent to the subscriber only when committed, and are then processed immediately by the subscriber.\u003c/p\u003e\u003cp\u003eThe implementation of two-phase commit requires that replication has successfully finished the initial table synchronization phase. So even when \u003ccode class=\"literal\"\u003etwo_phase\u003c/code\u003e is enabled for a subscription, the internal two-phase state remains temporarily \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003epending\u003c/span\u003e”\u003c/span\u003e until the initialization phase completes. See column \u003ccode class=\"structfield\"\u003esubtwophasestate\u003c/code\u003e of \u003ca href=\"/docs/18/catalog-pg-subscription.html\" title=\"52.54. pg_subscription\"\u003e\u003ccode class=\"structname\"\u003epg_subscription\u003c/code\u003e\u003c/a\u003e to know the actual two-phase state.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003edisable_on_error\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eSpecifies whether the subscription should be automatically disabled if any errors are detected by subscription workers during data replication from the publisher. The default is \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epassword_required\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eIf set to \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, connections to the publisher made as a result of this subscription must use password authentication and the password must be specified as a part of the connection string. This setting is ignored when the subscription is owned by a superuser. The default is \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e. Only superusers can set this value to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003erun_as_owner\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eIf true, all replication actions are performed as the subscription owner. If false, replication workers will perform actions on each table as the owner of that table. The latter configuration is generally much more secure; for details, see \u003ca href=\"/docs/18/logical-replication-security.html\" title=\"29.11. Security\"\u003eSection 29.11\u003c/a\u003e. The default is \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eorigin\u003c/code\u003e (\u003ccode class=\"type\"\u003estring\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eSpecifies whether the subscription will request the publisher to only send changes that don't have an origin or send changes regardless of origin. Setting \u003ccode class=\"literal\"\u003eorigin\u003c/code\u003e to \u003ccode class=\"literal\"\u003enone\u003c/code\u003e means that the subscription will request the publisher to only send changes that don't have an origin. Setting \u003ccode class=\"literal\"\u003eorigin\u003c/code\u003e to \u003ccode class=\"literal\"\u003eany\u003c/code\u003e means that the publisher sends changes regardless of their origin. The default is \u003ccode class=\"literal\"\u003eany\u003c/code\u003e.\u003c/p\u003e\u003cp\u003eSee \u003ca href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-NOTES\" title=\"Notes\"\u003eNotes\u003c/a\u003e for details of how \u003ccode class=\"literal\"\u003ecopy_data = true\u003c/code\u003e can interact with the \u003ccode class=\"literal\"\u003eorigin\u003c/code\u003e parameter.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003efailover\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eSpecifies whether the replication slots associated with the subscription are enabled to be synced to the standbys so that logical replication can be resumed from the new primary after failover. The default is \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003eWhen specifying a parameter of type \u003ccode class=\"type\"\u003eboolean\u003c/code\u003e, the \u003ccode class=\"literal\"\u003e=\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e part can be omitted, which is equivalent to specifying \u003ccode class=\"literal\"\u003eTRUE\u003c/code\u003e.\u003c/p\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eSee \u003ca href=\"/docs/18/logical-replication-security.html\" title=\"29.11. Security\"\u003eSection 29.11\u003c/a\u003e for details on how to configure access control between the subscription and the publication instance.\u003c/p\u003e\u003cp\u003eWhen creating a replication slot (the default behavior), \u003ccode class=\"command\"\u003eCREATE SUBSCRIPTION\u003c/code\u003e cannot be executed inside a transaction block.\u003c/p\u003e\u003cp\u003eCreating a subscription that connects to the same database cluster (for example, to replicate between databases in the same cluster or to replicate within the same database) will only succeed if the replication slot is not created as part of the same command. Otherwise, the \u003ccode class=\"command\"\u003eCREATE SUBSCRIPTION\u003c/code\u003e call will hang. To make this work, create the replication slot separately (using the function \u003ccode class=\"function\"\u003epg_create_logical_replication_slot\u003c/code\u003e with the plugin name \u003ccode class=\"literal\"\u003epgoutput\u003c/code\u003e) and create the subscription using the parameter \u003ccode class=\"literal\"\u003ecreate_slot = false\u003c/code\u003e. See \u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" title=\"29.2.3. Examples: Deferred Replication Slot Creation\"\u003eSection 29.2.3\u003c/a\u003e for examples. This is an implementation restriction that might be lifted in a future release.\u003c/p\u003e\u003cp\u003eIf any table in the publication has a \u003ccode class=\"literal\"\u003eWHERE\u003c/code\u003e clause, rows for which the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e evaluates to \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e or \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e will not be published. If the subscription has several publications in which the same table has been published with different \u003ccode class=\"literal\"\u003eWHERE\u003c/code\u003e clauses, a row will be published if any of the expressions (referring to that publish operation) are satisfied. In the case of different \u003ccode class=\"literal\"\u003eWHERE\u003c/code\u003e clauses, if one of the publications has no \u003ccode class=\"literal\"\u003eWHERE\u003c/code\u003e clause (referring to that publish operation) or the publication is declared as \u003ca href=\"/docs/18/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-FOR-ALL-TABLES\"\u003e\u003ccode class=\"literal\"\u003eFOR ALL TABLES\u003c/code\u003e\u003c/a\u003e or \u003ca href=\"/docs/18/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-FOR-TABLES-IN-SCHEMA\"\u003e\u003ccode class=\"literal\"\u003eFOR TABLES IN SCHEMA\u003c/code\u003e\u003c/a\u003e, rows are always published regardless of the definition of the other expressions. If the subscriber is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e version before 15, then any row filtering is ignored during the initial data synchronization phase. For this case, the user might want to consider deleting any initially copied data that would be incompatible with subsequent filtering. Because initial data synchronization does not take into account the publication \u003ca href=\"/docs/18/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-WITH-PUBLISH\"\u003e\u003ccode class=\"literal\"\u003epublish\u003c/code\u003e\u003c/a\u003e parameter when copying existing table data, some rows may be copied that would not be replicated using DML. See \u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES\" title=\"29.2.2. Examples: Set Up Logical Replication\"\u003eSection 29.2.2\u003c/a\u003e for examples.\u003c/p\u003e\u003cp\u003eSubscriptions having several publications in which the same table has been published with different column lists are not supported.\u003c/p\u003e\u003cp\u003eWe allow non-existent publications to be specified so that users can add those later. This means \u003ca href=\"/docs/18/catalog-pg-subscription.html\" title=\"52.54. pg_subscription\"\u003e\u003ccode class=\"structname\"\u003epg_subscription\u003c/code\u003e\u003c/a\u003e can have non-existent publications.\u003c/p\u003e\u003cp\u003eWhen using a subscription parameter combination of \u003ccode class=\"literal\"\u003ecopy_data = true\u003c/code\u003e and \u003ccode class=\"literal\"\u003eorigin = NONE\u003c/code\u003e, the initial sync table data is copied directly from the publisher, meaning that knowledge of the true origin of that data is not possible. If the publisher also has subscriptions then the copied table data might have originated from further upstream. This scenario is detected and a WARNING is logged to the user, but the warning is only an indication of a potential problem; it is the user's responsibility to make the necessary checks to ensure the copied data origins are really as wanted or not.\u003c/p\u003e\u003cp\u003eTo find which tables might potentially include non-local origins (due to other subscriptions created on the publisher) try this SQL query:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e# substitute \u0026lt;pub-names\u0026gt; below with your publication name(s) to be queried\nSELECT DISTINCT PT.schemaname, PT.tablename\nFROM pg_publication_tables PT\n     JOIN pg_class C ON (C.relname = PT.tablename)\n     JOIN pg_namespace N ON (N.nspname = PT.schemaname),\n     pg_subscription_rel PS\nWHERE C.relnamespace = N.oid AND\n      (PS.srrelid = C.oid OR\n      C.oid IN (SELECT relid FROM pg_partition_ancestors(PS.srrelid) UNION\n                SELECT relid FROM pg_partition_tree(PS.srrelid))) AND\n      PT.pubname IN (\u0026lt;pub-names\u0026gt;);\n\u003c/pre\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eCreate a subscription to a remote server that replicates tables in the publications \u003ccode class=\"literal\"\u003emypublication\u003c/code\u003e and \u003ccode class=\"literal\"\u003einsert_only\u003c/code\u003e and starts replicating immediately on commit:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE SUBSCRIPTION mysub\n         CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb'\n        PUBLICATION mypublication, insert_only;\n\u003c/pre\u003e\u003cp\u003eCreate a subscription to a remote server that replicates tables in the \u003ccode class=\"literal\"\u003einsert_only\u003c/code\u003e publication and does not start replicating until enabled at a later time.\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE SUBSCRIPTION mysub\n         CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb'\n        PUBLICATION insert_only\n               WITH (enabled = false);\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE SUBSCRIPTION\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/alter-subscription/?v=18\" title=\"ALTER SUBSCRIPTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER SUBSCRIPTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-subscription/?v=18\" title=\"DROP SUBSCRIPTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP SUBSCRIPTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-publication/?v=18\" title=\"CREATE PUBLICATION\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE PUBLICATION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-publication/?v=18\" title=\"ALTER PUBLICATION\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER PUBLICATION\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"CREATE SUBSCRIPTION \u003cem class=\"replaceable\"\u003e\u003ccode\u003esubscription_name\u003c/code\u003e\u003c/em\u003e\n    CONNECTION '\u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e'\n    PUBLICATION \u003cem class=\"replaceable\"\u003e\u003ccode\u003epublication_name\u003c/code\u003e\u003c/em\u003e [, ...]\n    [ WITH ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003esubscription_parameter\u003c/code\u003e\u003c/em\u003e [= \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e] [, ... ] ) ]","synopsis_text":"CREATE SUBSCRIPTION subscription_name\nCONNECTION 'conninfo'\nPUBLICATION publication_name [, ...]\n[ WITH ( subscription_parameter [= value] [, ... ] ) ]"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"create-subscription","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"CREATE SUBSCRIPTION","Summary":"定义一个新的订阅","BodyHTML":"\u003cpre\u003eCREATE SUBSCRIPTION subscription_name\nCONNECTION \u0026#39;conninfo\u0026#39;\nPUBLICATION publication_name [, ...]\n[ WITH ( subscription_parameter [= value] [, ... ] ) ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCREATE SUBSCRIPTION\u003c/code\u003e添加一个新的逻辑复制订阅。创建订阅的用户将成为该订阅的所有者。订阅名称必须与当前数据库中任何现有订阅的名称不同。\u003c/p\u003e\u003cp\u003e订阅表示与发布者的复制连接。因此，除了在本地系统目录中添加定义之外，该命令通常还会在发布者上创建一个复制槽。\u003c/p\u003e\u003cp\u003e除非订阅初始即被禁用，否则在执行该命令所在事务提交时，会启动一个逻辑复制工作进程为新订阅复制数据。\u003c/p\u003e\u003cp\u003e要能够创建订阅，必须具有\u003ccode\u003epg_create_subscription\u003c/code\u003e角色的权限，以及当前数据库上的\u003ccode\u003eCREATE\u003c/code\u003e权限。\u003c/p\u003e\u003cp\u003e关于订阅以及整个逻辑复制的更多信息，请参见\u003ca href=\"/docs/18/logical-replication-subscription.html\" rel=\"nofollow\"\u003e第 29.2 节\u003c/a\u003e和\u003ca href=\"/docs/18/logical-replication.html\" rel=\"nofollow\"\u003e第 29 章\u003c/a\u003e。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003esubscription_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e新订阅的名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eCONNECTION \u0026#39;\u003cem\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e\u0026#39;\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e定义如何连接到发布者数据库的\u003cspan\u003elibpq\u003c/span\u003e连接字符串。详情请参见\u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" rel=\"nofollow\"\u003e第 32.1.1 节\u003c/a\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ePUBLICATION \u003cem\u003e\u003ccode\u003epublication_name\u003c/code\u003e\u003c/em\u003e [, ...]\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e要订阅的发布者上的发布名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eWITH ( \u003cem\u003e\u003ccode\u003esubscription_parameter\u003c/code\u003e\u003c/em\u003e [= \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e] [, ... ] )\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该子句为订阅指定可选参数。\u003c/p\u003e\u003cp\u003e下列参数控制订阅创建期间的行为：\u003c/p\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003econnect\u003c/code\u003e (\u003ccode\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定\u003ccode\u003eCREATE SUBSCRIPTION\u003c/code\u003e命令是否连接到发布者。默认值为\u003ccode\u003etrue\u003c/code\u003e。将其设为 \u003ccode\u003efalse\u003c/code\u003e会强制把\u003ccode\u003ecreate_slot\u003c/code\u003e、\u003ccode\u003eenabled\u003c/code\u003e和\u003ccode\u003ecopy_data\u003c/code\u003e的值设为\u003ccode\u003efalse\u003c/code\u003e。（不能将\u003ccode\u003econnect\u003c/code\u003e 设为\u003ccode\u003efalse\u003c/code\u003e的同时，再把\u003ccode\u003ecreate_slot\u003c/code\u003e、\u003ccode\u003eenabled\u003c/code\u003e或\u003ccode\u003ecopy_data\u003c/code\u003e设为 \u003ccode\u003etrue\u003c/code\u003e。）\u003c/p\u003e\u003cp\u003e由于该选项为\u003ccode\u003efalse\u003c/code\u003e时不会建立连接，因此不会订阅任何表。要启动复制，你必须手工创建复制槽、在需要时启用故障切换、启用订阅，并刷新订阅。示例见\u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" rel=\"nofollow\"\u003e第 29.2.3 节\u003c/a\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ecreate_slot\u003c/code\u003e (\u003ccode\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定该命令是否应在发布者上创建复制槽。默认值为 \u003ccode\u003etrue\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e如果设为\u003ccode\u003efalse\u003c/code\u003e，则必须以其他方式自行创建发布者上的复制槽。示例见\u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" rel=\"nofollow\"\u003e第 29.2.3 节\u003c/a\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eenabled\u003c/code\u003e (\u003ccode\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定订阅是应当主动进行复制，还是仅完成设置但暂不启动。默认值为\u003ccode\u003etrue\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eslot_name\u003c/code\u003e (\u003ccode\u003estring\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e要使用的发布者上的复制槽名称。默认使用订阅名称作为槽名。\u003c/p\u003e\u003cp\u003e将\u003ccode\u003eslot_name\u003c/code\u003e设为\u003ccode\u003eNONE\u003c/code\u003e表示该订阅不关联任何复制槽。这类订阅还必须同时将\u003ccode\u003eenabled\u003c/code\u003e 和\u003ccode\u003ecreate_slot\u003c/code\u003e设为\u003ccode\u003efalse\u003c/code\u003e。当你打算稍后手工创建复制槽时，可使用此设置。示例见\u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" rel=\"nofollow\"\u003e第 29.2.3 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e将\u003ccode\u003eslot_name\u003c/code\u003e设为有效名称且 \u003ccode\u003ecreate_slot\u003c/code\u003e设为\u003ccode\u003efalse\u003c/code\u003e时，所指定复制槽的\u003ccode\u003efailover\u003c/code\u003e属性值可能与订阅中对应的 \u003ccode\u003efailover\u003c/code\u003e参数不同。应始终确保该槽的 \u003ccode\u003efailover\u003c/code\u003e属性与订阅中的对应参数一致，反之亦然。否则，发布者上的该槽的行为可能与这些订阅选项所表明的不同：例如，即使订阅的\u003ccode\u003efailover\u003c/code\u003e选项已禁用，发布者上的该槽仍可能被同步到备库；或者即使订阅的\u003ccode\u003efailover\u003c/code\u003e选项已启用，该槽也可能不会被同步到备库。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e下列参数控制订阅创建后的复制行为：\u003c/p\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ebinary\u003c/code\u003e (\u003ccode\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定订阅是否请求发布者以二进制格式（而不是文本格式）发送数据。默认值为\u003ccode\u003efalse\u003c/code\u003e。任何初始表同步复制（见\u003ccode\u003ecopy_data\u003c/code\u003e）也使用相同格式。二进制格式可能比文本格式更快，但在不同机器架构和 \u003cspan\u003ePostgreSQL\u003c/span\u003e版本之间的可移植性较差。二进制格式对数据类型非常敏感；例如，虽然在文本格式下可以正常工作，但它不允许从\u003ccode\u003esmallint\u003c/code\u003e列复制到\u003ccode\u003einteger\u003c/code\u003e列。即使启用了此选项，也只有具有二进制发送和接收函数的数据类型才会以二进制方式传输。注意，初始同步要求所有数据类型都具有二进制发送和接收函数，否则同步将失败（关于发送/接收函数的更多信息，请参见\u003ca href=\"/docs/18/sql-createtype.html\" title=\"CREATE TYPE\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE TYPE\u003c/span\u003e\u003c/a\u003e）。\u003c/p\u003e\u003cp\u003e在进行跨版本复制时，可能会出现这样的情况：发布者对某种数据类型有二进制发送函数，但订阅者缺少该类型的二进制接收函数。在这种情况下，数据传输会失败，因此不能使用\u003ccode\u003ebinary\u003c/code\u003e选项。\u003c/p\u003e\u003cp\u003e如果发布者使用的是 16 之前版本的 \u003cspan\u003ePostgreSQL\u003c/span\u003e，那么即使 \u003ccode\u003ebinary = true\u003c/code\u003e，任何初始表同步也都会使用文本格式。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ecopy_data\u003c/code\u003e (\u003ccode\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定复制开始时是否复制所订阅发布中的预先存在的数据。默认值为\u003ccode\u003etrue\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e如果这些发布包含\u003ccode\u003eWHERE\u003c/code\u003e子句，将会影响被复制的数据。详情请参见\u003ca href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-NOTES\" title=\"注解\" rel=\"nofollow\"\u003e注意\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e关于\u003ccode\u003ecopy_data = true\u003c/code\u003e如何与 \u003ccode\u003eorigin\u003c/code\u003e参数相互作用的细节，请参见\u003ca href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-NOTES\" title=\"注解\" rel=\"nofollow\"\u003e注意\u003c/a\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003estreaming\u003c/code\u003e (\u003ccode\u003eenum\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定是否为该订阅启用进行中事务的流式传输。默认值为 \u003ccode\u003eparallel\u003c/code\u003e，表示如果有可用的并行应用工作进程，接收到的更改会直接通过其中之一应用。如果没有空闲的并行应用工作进程可以处理流式事务，那么这些更改会写入临时文件，并在事务提交后再应用。注意，如果并行应用工作进程中发生错误，远端事务的完成 LSN 可能不会记录到服务器日志中。\u003c/p\u003e\u003cdiv\u003e\u003ch3\u003e小心\u003c/h3\u003e\u003cp\u003e当发布者与订阅者的模式不同时，存在发生死锁的风险，尽管这种情况很少见。应用工作进程会自动重试这些事务。\u003c/p\u003e\u003c/div\u003e\u003cp\u003e如果设为\u003ccode\u003eon\u003c/code\u003e，接收到的更改会写入临时文件，然后仅在事务在发布者上提交且被订阅者接收之后才应用。\u003c/p\u003e\u003cp\u003e如果设为\u003ccode\u003eoff\u003c/code\u003e，所有事务都会先在发布者上完全解码，然后才整体发送给订阅者。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003esynchronous_commit\u003c/code\u003e (\u003ccode\u003eenum\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该参数的值会覆盖此订阅应用工作进程中的\u003ca href=\"/docs/18/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT\" rel=\"nofollow\"\u003esynchronous_commit\u003c/a\u003e设置。默认值为 \u003ccode\u003eoff\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e对逻辑复制来说，使用\u003ccode\u003eoff\u003c/code\u003e是安全的：如果订阅者因缺少同步而丢失了事务，数据会再次从发布者发送过来。\u003c/p\u003e\u003cp\u003e在进行同步逻辑复制时，可能更适合使用不同的设置。逻辑复制工作进程会向发布者报告写入和刷盘位置，而在使用同步复制时，发布者会等待真正的刷盘完成。这意味着，当订阅被用于同步复制时，将订阅者的 \u003ccode\u003esynchronous_commit\u003c/code\u003e设为\u003ccode\u003eoff\u003c/code\u003e 可能会增加发布者上\u003ccode\u003eCOMMIT\u003c/code\u003e的延迟。在这种场景下，将\u003ccode\u003esynchronous_commit\u003c/code\u003e设为\u003ccode\u003elocal\u003c/code\u003e 或更高可能更有利。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003etwo_phase\u003c/code\u003e (\u003ccode\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定是否为该订阅启用两阶段提交。默认值为 \u003ccode\u003efalse\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e启用两阶段提交时，预备事务会在 \u003ccode\u003ePREPARE TRANSACTION\u003c/code\u003e时发送给订阅者，并且在订阅者上也会作为两阶段事务处理。否则，预备事务只有在提交时才会发送给订阅者，随后由订阅者立即处理。\u003c/p\u003e\u003cp\u003e两阶段提交的实现要求复制已经成功完成初始表同步阶段。因此，即使订阅启用了\u003ccode\u003etwo_phase\u003c/code\u003e，内部的两阶段状态也会暂时保持为\u003cspan\u003e“\u003cspan\u003epending\u003c/span\u003e”\u003c/span\u003e，直到初始化阶段完成。要了解实际的两阶段状态，请参见 \u003ca href=\"/docs/18/catalog-pg-subscription.html\" rel=\"nofollow\"\u003e\u003ccode\u003epg_subscription\u003c/code\u003e\u003c/a\u003e 的\u003ccode\u003esubtwophasestate\u003c/code\u003e列。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003edisable_on_error\u003c/code\u003e (\u003ccode\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定如果订阅工作进程在从发布者复制数据期间检测到任何错误，是否自动禁用该订阅。默认值为\u003ccode\u003efalse\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003epassword_required\u003c/code\u003e (\u003ccode\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e如果设为\u003ccode\u003etrue\u003c/code\u003e，则由于该订阅而建立的到发布者的连接必须使用密码认证，并且密码必须作为连接字符串的一部分指定。如果该订阅由超级用户拥有，则此设置会被忽略。默认值为\u003ccode\u003etrue\u003c/code\u003e。只有超级用户才能将该值设为\u003ccode\u003efalse\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003erun_as_owner\u003c/code\u003e (\u003ccode\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e如果为\u003ccode\u003etrue\u003c/code\u003e，所有复制操作都以订阅所有者的身份执行。如果为\u003ccode\u003efalse\u003c/code\u003e，复制工作进程会在每张表上以该表所有者的身份执行操作。后一种配置通常安全得多；详情请参见\u003ca href=\"/docs/18/logical-replication-security.html\" rel=\"nofollow\"\u003e第 29.11 节\u003c/a\u003e。默认值为\u003ccode\u003efalse\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eorigin\u003c/code\u003e (\u003ccode\u003estring\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定订阅是请求发布者仅发送没有复制源的更改，还是无论复制源如何都发送更改。将\u003ccode\u003eorigin\u003c/code\u003e设为\u003ccode\u003enone\u003c/code\u003e表示订阅会请求发布者仅发送没有复制源的更改。将\u003ccode\u003eorigin\u003c/code\u003e设为 \u003ccode\u003eany\u003c/code\u003e表示发布者无论复制源如何都发送更改。默认值为 \u003ccode\u003eany\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e关于\u003ccode\u003ecopy_data = true\u003c/code\u003e如何与 \u003ccode\u003eorigin\u003c/code\u003e参数相互作用的细节，请参见\u003ca href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-NOTES\" title=\"注解\" rel=\"nofollow\"\u003e注意\u003c/a\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003efailover\u003c/code\u003e (\u003ccode\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定与该订阅关联的复制槽是否启用同步到备库，以便在故障切换后能够从新的主库继续逻辑复制。默认值为\u003ccode\u003efalse\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e当指定\u003ccode\u003eboolean\u003c/code\u003e类型的参数时，可以省略 \u003ccode\u003e=\u003c/code\u003e \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e 部分，这等价于指定\u003ccode\u003eTRUE\u003c/code\u003e。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e关于如何在订阅与发布实例之间配置访问控制，详见\u003ca href=\"/docs/18/logical-replication-security.html\" rel=\"nofollow\"\u003e第 29.11 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e当创建复制槽时（这是默认行为），\u003ccode\u003eCREATE SUBSCRIPTION\u003c/code\u003e不能在事务块内部执行。\u003c/p\u003e\u003cp\u003e创建一个连接到同一数据库集簇的订阅（例如在同一集簇中的不同数据库之间复制，或者在同一数据库内复制）时，只有在复制槽不作为同一命令的一部分创建的情况下才会成功。否则，\u003ccode\u003eCREATE SUBSCRIPTION\u003c/code\u003e 调用将挂起。要实现这种用法，应分别创建复制槽（使用函数 \u003ccode\u003epg_create_logical_replication_slot\u003c/code\u003e并指定插件名 \u003ccode\u003epgoutput\u003c/code\u003e），然后使用参数 \u003ccode\u003ecreate_slot = false\u003c/code\u003e创建订阅。示例见\u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" rel=\"nofollow\"\u003e第 29.2.3 节\u003c/a\u003e。这是一个实现限制，未来版本中可能会解除。\u003c/p\u003e\u003cp\u003e如果发布中的任何表带有\u003ccode\u003eWHERE\u003c/code\u003e子句，则对 \u003cem\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e求值为 \u003ccode\u003efalse\u003c/code\u003e或\u003ccode\u003eNULL\u003c/code\u003e的行不会被发布。如果订阅包含多个发布，且同一张表在这些发布中使用了不同的 \u003ccode\u003eWHERE\u003c/code\u003e子句，那么只要任意一个表达式（针对相应的发布操作）满足，该行就会被发布。对于不同的 \u003ccode\u003eWHERE\u003c/code\u003e子句，如果其中某个发布没有 \u003ccode\u003eWHERE\u003c/code\u003e子句（针对相应的发布操作），或者该发布被声明为 \u003ca href=\"/docs/18/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-FOR-ALL-TABLES\" rel=\"nofollow\"\u003e\u003ccode\u003eFOR ALL TABLES\u003c/code\u003e\u003c/a\u003e 或 \u003ca href=\"/docs/18/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-FOR-TABLES-IN-SCHEMA\" rel=\"nofollow\"\u003e\u003ccode\u003eFOR TABLES IN SCHEMA\u003c/code\u003e\u003c/a\u003e，则无论其他表达式如何定义，该行都会被发布。如果订阅者使用的是 15 之前版本的\u003cspan\u003ePostgreSQL\u003c/span\u003e，那么在初始数据同步阶段会忽略所有行过滤。在这种情况下，用户可能需要考虑删除那些初始复制过来、但与后续过滤不兼容的数据。由于初始数据同步在复制现有表数据时不会考虑发布的 \u003ca href=\"/docs/18/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-WITH-PUBLISH\" rel=\"nofollow\"\u003e\u003ccode\u003epublish\u003c/code\u003e\u003c/a\u003e 参数，因此有些使用 DML 时本不会复制的行，也可能在此阶段被复制。示例见\u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES\" rel=\"nofollow\"\u003e第 29.2.2 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e如果订阅包含多个发布，而其中同一张表使用了不同的列列表进行发布，则不受支持。\u003c/p\u003e\u003cp\u003e允许指定不存在的发布，以便用户稍后再创建这些发布。这意味着 \u003ca href=\"/docs/18/catalog-pg-subscription.html\" rel=\"nofollow\"\u003e\u003ccode\u003epg_subscription\u003c/code\u003e\u003c/a\u003e 中可能包含不存在的发布。\u003c/p\u003e\u003cp\u003e当使用\u003ccode\u003ecopy_data = true\u003c/code\u003e和 \u003ccode\u003eorigin = NONE\u003c/code\u003e这一订阅参数组合时，初始同步的表数据会直接从发布者复制过来，因此无法得知这些数据的真实来源。如果发布者本身也有订阅，那么复制过来的表数据可能来自更上游。系统会检测到这种情况，并向用户发出一条\u003ccode\u003eWARNING\u003c/code\u003e，但这条警告只表明可能存在问题；用户仍需自行进行必要检查，以确认复制过来的数据来源是否确实符合预期。\u003c/p\u003e\u003cp\u003e若要找出哪些表可能包含非本地来源的数据（由于在发布者上创建了其他订阅），可以尝试执行以下 SQL 查询：\u003c/p\u003e\u003cpre\u003e# substitute \u0026lt;pub-names\u0026gt; below with your publication name(s) to be queried\nSELECT DISTINCT PT.schemaname, PT.tablename\nFROM pg_publication_tables PT\n     JOIN pg_class C ON (C.relname = PT.tablename)\n     JOIN pg_namespace N ON (N.nspname = PT.schemaname),\n     pg_subscription_rel PS\nWHERE C.relnamespace = N.oid AND\n      (PS.srrelid = C.oid OR\n      C.oid IN (SELECT relid FROM pg_partition_ancestors(PS.srrelid) UNION\n                SELECT relid FROM pg_partition_tree(PS.srrelid))) AND\n      PT.pubname IN (\u0026lt;pub-names\u0026gt;);\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e创建一个指向远端服务器的订阅，复制发布 \u003ccode\u003emypublication\u003c/code\u003e和\u003ccode\u003einsert_only\u003c/code\u003e中的表，并在提交时立即开始复制：\u003c/p\u003e\u003cpre\u003eCREATE SUBSCRIPTION mysub\n         CONNECTION \u0026#39;host=192.168.1.50 port=5432 user=foo dbname=foodb\u0026#39;\n        PUBLICATION mypublication, insert_only;\n\u003c/pre\u003e\u003cp\u003e创建一个指向远端服务器的订阅，复制\u003ccode\u003einsert_only\u003c/code\u003e发布中的表，并且要等到稍后启用时才开始复制。\u003c/p\u003e\u003cpre\u003eCREATE SUBSCRIPTION mysub\n         CONNECTION \u0026#39;host=192.168.1.50 port=5432 user=foo dbname=foodb\u0026#39;\n        PUBLICATION insert_only\n               WITH (enabled = false);\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCREATE SUBSCRIPTION\u003c/code\u003e是 \u003cspan\u003ePostgreSQL\u003c/span\u003e扩展。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/alter-subscription/?v=18\" title=\"ALTER SUBSCRIPTION\" rel=\"nofollow\"\u003e\u003cspan\u003eALTER SUBSCRIPTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-subscription/?v=18\" title=\"DROP SUBSCRIPTION\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP SUBSCRIPTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-publication/?v=18\" title=\"CREATE PUBLICATION\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE PUBLICATION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-publication/?v=18\" title=\"ALTER PUBLICATION\" rel=\"nofollow\"\u003e\u003cspan\u003eALTER PUBLICATION\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"f54aa6d7dd2643c976049c50ffd2fc459426083a7f37c6177bc437d9defcf2e2","Payload":{"purpose_zh":"定义一个新的订阅","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE SUBSCRIPTION\u003c/code\u003e添加一个新的逻辑复制订阅。创建订阅的用户将成为该订阅的所有者。订阅名称必须与当前数据库中任何现有订阅的名称不同。\u003c/p\u003e\u003cp\u003e订阅表示与发布者的复制连接。因此，除了在本地系统目录中添加定义之外，该命令通常还会在发布者上创建一个复制槽。\u003c/p\u003e\u003cp\u003e除非订阅初始即被禁用，否则在执行该命令所在事务提交时，会启动一个逻辑复制工作进程为新订阅复制数据。\u003c/p\u003e\u003cp\u003e要能够创建订阅，必须具有\u003ccode class=\"literal\"\u003epg_create_subscription\u003c/code\u003e角色的权限，以及当前数据库上的\u003ccode class=\"literal\"\u003eCREATE\u003c/code\u003e权限。\u003c/p\u003e\u003cp\u003e关于订阅以及整个逻辑复制的更多信息，请参见\u003ca href=\"/docs/18/logical-replication-subscription.html\" title=\"29.2. 订阅\"\u003e第 29.2 节\u003c/a\u003e和\u003ca href=\"/docs/18/logical-replication.html\" title=\"第 29 章 逻辑复制\"\u003e第 29 章\u003c/a\u003e。\u003c/p\u003e","key":"description","title":"描述"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esubscription_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e新订阅的名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eCONNECTION '\u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e'\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e定义如何连接到发布者数据库的\u003cspan class=\"application\"\u003elibpq\u003c/span\u003e连接字符串。详情请参见\u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. 连接字符串\"\u003e第 32.1.1 节\u003c/a\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ePUBLICATION \u003cem class=\"replaceable\"\u003e\u003ccode\u003epublication_name\u003c/code\u003e\u003c/em\u003e [, ...]\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e要订阅的发布者上的发布名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eWITH ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003esubscription_parameter\u003c/code\u003e\u003c/em\u003e [= \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e] [, ... ] )\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该子句为订阅指定可选参数。\u003c/p\u003e\u003cp\u003e下列参数控制订阅创建期间的行为：\u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003econnect\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定\u003ccode class=\"command\"\u003eCREATE SUBSCRIPTION\u003c/code\u003e命令是否连接到发布者。默认值为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e。将其设为 \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e会强制把\u003ccode class=\"literal\"\u003ecreate_slot\u003c/code\u003e、\u003ccode class=\"literal\"\u003eenabled\u003c/code\u003e和\u003ccode class=\"literal\"\u003ecopy_data\u003c/code\u003e的值设为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。（不能将\u003ccode class=\"literal\"\u003econnect\u003c/code\u003e 设为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e的同时，再把\u003ccode class=\"literal\"\u003ecreate_slot\u003c/code\u003e、\u003ccode class=\"literal\"\u003eenabled\u003c/code\u003e或\u003ccode class=\"literal\"\u003ecopy_data\u003c/code\u003e设为 \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e。）\u003c/p\u003e\u003cp\u003e由于该选项为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e时不会建立连接，因此不会订阅任何表。要启动复制，你必须手工创建复制槽、在需要时启用故障切换、启用订阅，并刷新订阅。示例见\u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" title=\"29.2.3. 示例：延迟创建复制槽\"\u003e第 29.2.3 节\u003c/a\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecreate_slot\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定该命令是否应在发布者上创建复制槽。默认值为 \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e如果设为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e，则必须以其他方式自行创建发布者上的复制槽。示例见\u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" title=\"29.2.3. 示例：延迟创建复制槽\"\u003e第 29.2.3 节\u003c/a\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eenabled\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定订阅是应当主动进行复制，还是仅完成设置但暂不启动。默认值为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eslot_name\u003c/code\u003e (\u003ccode class=\"type\"\u003estring\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e要使用的发布者上的复制槽名称。默认使用订阅名称作为槽名。\u003c/p\u003e\u003cp\u003e将\u003ccode class=\"literal\"\u003eslot_name\u003c/code\u003e设为\u003ccode class=\"literal\"\u003eNONE\u003c/code\u003e表示该订阅不关联任何复制槽。这类订阅还必须同时将\u003ccode class=\"literal\"\u003eenabled\u003c/code\u003e 和\u003ccode class=\"literal\"\u003ecreate_slot\u003c/code\u003e设为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。当你打算稍后手工创建复制槽时，可使用此设置。示例见\u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" title=\"29.2.3. 示例：延迟创建复制槽\"\u003e第 29.2.3 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e将\u003ccode class=\"literal\"\u003eslot_name\u003c/code\u003e设为有效名称且 \u003ccode class=\"literal\"\u003ecreate_slot\u003c/code\u003e设为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e时，所指定复制槽的\u003ccode class=\"literal\"\u003efailover\u003c/code\u003e属性值可能与订阅中对应的 \u003ccode class=\"literal\"\u003efailover\u003c/code\u003e参数不同。应始终确保该槽的 \u003ccode class=\"literal\"\u003efailover\u003c/code\u003e属性与订阅中的对应参数一致，反之亦然。否则，发布者上的该槽的行为可能与这些订阅选项所表明的不同：例如，即使订阅的\u003ccode class=\"literal\"\u003efailover\u003c/code\u003e选项已禁用，发布者上的该槽仍可能被同步到备库；或者即使订阅的\u003ccode class=\"literal\"\u003efailover\u003c/code\u003e选项已启用，该槽也可能不会被同步到备库。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e下列参数控制订阅创建后的复制行为：\u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ebinary\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定订阅是否请求发布者以二进制格式（而不是文本格式）发送数据。默认值为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。任何初始表同步复制（见\u003ccode class=\"literal\"\u003ecopy_data\u003c/code\u003e）也使用相同格式。二进制格式可能比文本格式更快，但在不同机器架构和 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e版本之间的可移植性较差。二进制格式对数据类型非常敏感；例如，虽然在文本格式下可以正常工作，但它不允许从\u003ccode class=\"type\"\u003esmallint\u003c/code\u003e列复制到\u003ccode class=\"type\"\u003einteger\u003c/code\u003e列。即使启用了此选项，也只有具有二进制发送和接收函数的数据类型才会以二进制方式传输。注意，初始同步要求所有数据类型都具有二进制发送和接收函数，否则同步将失败（关于发送/接收函数的更多信息，请参见\u003ca href=\"/docs/18/sql-createtype.html\" title=\"CREATE TYPE\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE TYPE\u003c/span\u003e\u003c/a\u003e）。\u003c/p\u003e\u003cp\u003e在进行跨版本复制时，可能会出现这样的情况：发布者对某种数据类型有二进制发送函数，但订阅者缺少该类型的二进制接收函数。在这种情况下，数据传输会失败，因此不能使用\u003ccode class=\"literal\"\u003ebinary\u003c/code\u003e选项。\u003c/p\u003e\u003cp\u003e如果发布者使用的是 16 之前版本的 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e，那么即使 \u003ccode class=\"literal\"\u003ebinary = true\u003c/code\u003e，任何初始表同步也都会使用文本格式。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecopy_data\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定复制开始时是否复制所订阅发布中的预先存在的数据。默认值为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e如果这些发布包含\u003ccode class=\"literal\"\u003eWHERE\u003c/code\u003e子句，将会影响被复制的数据。详情请参见\u003ca href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-NOTES\" title=\"注解\"\u003e注意\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e关于\u003ccode class=\"literal\"\u003ecopy_data = true\u003c/code\u003e如何与 \u003ccode class=\"literal\"\u003eorigin\u003c/code\u003e参数相互作用的细节，请参见\u003ca href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-NOTES\" title=\"注解\"\u003e注意\u003c/a\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003estreaming\u003c/code\u003e (\u003ccode class=\"type\"\u003eenum\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定是否为该订阅启用进行中事务的流式传输。默认值为 \u003ccode class=\"literal\"\u003eparallel\u003c/code\u003e，表示如果有可用的并行应用工作进程，接收到的更改会直接通过其中之一应用。如果没有空闲的并行应用工作进程可以处理流式事务，那么这些更改会写入临时文件，并在事务提交后再应用。注意，如果并行应用工作进程中发生错误，远端事务的完成 LSN 可能不会记录到服务器日志中。\u003c/p\u003e\u003cdiv class=\"caution\"\u003e\u003ch3\u003e小心\u003c/h3\u003e\u003cp\u003e当发布者与订阅者的模式不同时，存在发生死锁的风险，尽管这种情况很少见。应用工作进程会自动重试这些事务。\u003c/p\u003e\u003c/div\u003e\u003cp\u003e如果设为\u003ccode class=\"literal\"\u003eon\u003c/code\u003e，接收到的更改会写入临时文件，然后仅在事务在发布者上提交且被订阅者接收之后才应用。\u003c/p\u003e\u003cp\u003e如果设为\u003ccode class=\"literal\"\u003eoff\u003c/code\u003e，所有事务都会先在发布者上完全解码，然后才整体发送给订阅者。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003esynchronous_commit\u003c/code\u003e (\u003ccode class=\"type\"\u003eenum\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该参数的值会覆盖此订阅应用工作进程中的\u003ca href=\"/docs/18/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT\"\u003esynchronous_commit\u003c/a\u003e设置。默认值为 \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e对逻辑复制来说，使用\u003ccode class=\"literal\"\u003eoff\u003c/code\u003e是安全的：如果订阅者因缺少同步而丢失了事务，数据会再次从发布者发送过来。\u003c/p\u003e\u003cp\u003e在进行同步逻辑复制时，可能更适合使用不同的设置。逻辑复制工作进程会向发布者报告写入和刷盘位置，而在使用同步复制时，发布者会等待真正的刷盘完成。这意味着，当订阅被用于同步复制时，将订阅者的 \u003ccode class=\"literal\"\u003esynchronous_commit\u003c/code\u003e设为\u003ccode class=\"literal\"\u003eoff\u003c/code\u003e 可能会增加发布者上\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e的延迟。在这种场景下，将\u003ccode class=\"literal\"\u003esynchronous_commit\u003c/code\u003e设为\u003ccode class=\"literal\"\u003elocal\u003c/code\u003e 或更高可能更有利。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etwo_phase\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定是否为该订阅启用两阶段提交。默认值为 \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e启用两阶段提交时，预备事务会在 \u003ccode class=\"command\"\u003ePREPARE TRANSACTION\u003c/code\u003e时发送给订阅者，并且在订阅者上也会作为两阶段事务处理。否则，预备事务只有在提交时才会发送给订阅者，随后由订阅者立即处理。\u003c/p\u003e\u003cp\u003e两阶段提交的实现要求复制已经成功完成初始表同步阶段。因此，即使订阅启用了\u003ccode class=\"literal\"\u003etwo_phase\u003c/code\u003e，内部的两阶段状态也会暂时保持为\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003epending\u003c/span\u003e”\u003c/span\u003e，直到初始化阶段完成。要了解实际的两阶段状态，请参见 \u003ca href=\"/docs/18/catalog-pg-subscription.html\" title=\"52.54. pg_subscription\"\u003e\u003ccode class=\"structname\"\u003epg_subscription\u003c/code\u003e\u003c/a\u003e 的\u003ccode class=\"structfield\"\u003esubtwophasestate\u003c/code\u003e列。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003edisable_on_error\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定如果订阅工作进程在从发布者复制数据期间检测到任何错误，是否自动禁用该订阅。默认值为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epassword_required\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e如果设为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e，则由于该订阅而建立的到发布者的连接必须使用密码认证，并且密码必须作为连接字符串的一部分指定。如果该订阅由超级用户拥有，则此设置会被忽略。默认值为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e。只有超级用户才能将该值设为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003erun_as_owner\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e如果为\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e，所有复制操作都以订阅所有者的身份执行。如果为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e，复制工作进程会在每张表上以该表所有者的身份执行操作。后一种配置通常安全得多；详情请参见\u003ca href=\"/docs/18/logical-replication-security.html\" title=\"29.11. 安全性\"\u003e第 29.11 节\u003c/a\u003e。默认值为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eorigin\u003c/code\u003e (\u003ccode class=\"type\"\u003estring\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定订阅是请求发布者仅发送没有复制源的更改，还是无论复制源如何都发送更改。将\u003ccode class=\"literal\"\u003eorigin\u003c/code\u003e设为\u003ccode class=\"literal\"\u003enone\u003c/code\u003e表示订阅会请求发布者仅发送没有复制源的更改。将\u003ccode class=\"literal\"\u003eorigin\u003c/code\u003e设为 \u003ccode class=\"literal\"\u003eany\u003c/code\u003e表示发布者无论复制源如何都发送更改。默认值为 \u003ccode class=\"literal\"\u003eany\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e关于\u003ccode class=\"literal\"\u003ecopy_data = true\u003c/code\u003e如何与 \u003ccode class=\"literal\"\u003eorigin\u003c/code\u003e参数相互作用的细节，请参见\u003ca href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-NOTES\" title=\"注解\"\u003e注意\u003c/a\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003efailover\u003c/code\u003e (\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e)\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定与该订阅关联的复制槽是否启用同步到备库，以便在故障切换后能够从新的主库继续逻辑复制。默认值为\u003ccode class=\"literal\"\u003efalse\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e当指定\u003ccode class=\"type\"\u003eboolean\u003c/code\u003e类型的参数时，可以省略 \u003ccode class=\"literal\"\u003e=\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e 部分，这等价于指定\u003ccode class=\"literal\"\u003eTRUE\u003c/code\u003e。\u003c/p\u003e","key":"parameters","title":"参数"},{"html":"\u003cp\u003e关于如何在订阅与发布实例之间配置访问控制，详见\u003ca href=\"/docs/18/logical-replication-security.html\" title=\"29.11. 安全性\"\u003e第 29.11 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e当创建复制槽时（这是默认行为），\u003ccode class=\"command\"\u003eCREATE SUBSCRIPTION\u003c/code\u003e不能在事务块内部执行。\u003c/p\u003e\u003cp\u003e创建一个连接到同一数据库集簇的订阅（例如在同一集簇中的不同数据库之间复制，或者在同一数据库内复制）时，只有在复制槽不作为同一命令的一部分创建的情况下才会成功。否则，\u003ccode class=\"command\"\u003eCREATE SUBSCRIPTION\u003c/code\u003e 调用将挂起。要实现这种用法，应分别创建复制槽（使用函数 \u003ccode class=\"function\"\u003epg_create_logical_replication_slot\u003c/code\u003e并指定插件名 \u003ccode class=\"literal\"\u003epgoutput\u003c/code\u003e），然后使用参数 \u003ccode class=\"literal\"\u003ecreate_slot = false\u003c/code\u003e创建订阅。示例见\u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES-DEFERRED-SLOT\" title=\"29.2.3. 示例：延迟创建复制槽\"\u003e第 29.2.3 节\u003c/a\u003e。这是一个实现限制，未来版本中可能会解除。\u003c/p\u003e\u003cp\u003e如果发布中的任何表带有\u003ccode class=\"literal\"\u003eWHERE\u003c/code\u003e子句，则对 \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e求值为 \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e或\u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e的行不会被发布。如果订阅包含多个发布，且同一张表在这些发布中使用了不同的 \u003ccode class=\"literal\"\u003eWHERE\u003c/code\u003e子句，那么只要任意一个表达式（针对相应的发布操作）满足，该行就会被发布。对于不同的 \u003ccode class=\"literal\"\u003eWHERE\u003c/code\u003e子句，如果其中某个发布没有 \u003ccode class=\"literal\"\u003eWHERE\u003c/code\u003e子句（针对相应的发布操作），或者该发布被声明为 \u003ca href=\"/docs/18/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-FOR-ALL-TABLES\"\u003e\u003ccode class=\"literal\"\u003eFOR ALL TABLES\u003c/code\u003e\u003c/a\u003e 或 \u003ca href=\"/docs/18/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-FOR-TABLES-IN-SCHEMA\"\u003e\u003ccode class=\"literal\"\u003eFOR TABLES IN SCHEMA\u003c/code\u003e\u003c/a\u003e，则无论其他表达式如何定义，该行都会被发布。如果订阅者使用的是 15 之前版本的\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e，那么在初始数据同步阶段会忽略所有行过滤。在这种情况下，用户可能需要考虑删除那些初始复制过来、但与后续过滤不兼容的数据。由于初始数据同步在复制现有表数据时不会考虑发布的 \u003ca href=\"/docs/18/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-WITH-PUBLISH\"\u003e\u003ccode class=\"literal\"\u003epublish\u003c/code\u003e\u003c/a\u003e 参数，因此有些使用 DML 时本不会复制的行，也可能在此阶段被复制。示例见\u003ca href=\"/docs/18/logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-EXAMPLES\" title=\"29.2.2. 示例：建立逻辑复制\"\u003e第 29.2.2 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e如果订阅包含多个发布，而其中同一张表使用了不同的列列表进行发布，则不受支持。\u003c/p\u003e\u003cp\u003e允许指定不存在的发布，以便用户稍后再创建这些发布。这意味着 \u003ca href=\"/docs/18/catalog-pg-subscription.html\" title=\"52.54. pg_subscription\"\u003e\u003ccode class=\"structname\"\u003epg_subscription\u003c/code\u003e\u003c/a\u003e 中可能包含不存在的发布。\u003c/p\u003e\u003cp\u003e当使用\u003ccode class=\"literal\"\u003ecopy_data = true\u003c/code\u003e和 \u003ccode class=\"literal\"\u003eorigin = NONE\u003c/code\u003e这一订阅参数组合时，初始同步的表数据会直接从发布者复制过来，因此无法得知这些数据的真实来源。如果发布者本身也有订阅，那么复制过来的表数据可能来自更上游。系统会检测到这种情况，并向用户发出一条\u003ccode class=\"literal\"\u003eWARNING\u003c/code\u003e，但这条警告只表明可能存在问题；用户仍需自行进行必要检查，以确认复制过来的数据来源是否确实符合预期。\u003c/p\u003e\u003cp\u003e若要找出哪些表可能包含非本地来源的数据（由于在发布者上创建了其他订阅），可以尝试执行以下 SQL 查询：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e# substitute \u0026lt;pub-names\u0026gt; below with your publication name(s) to be queried\nSELECT DISTINCT PT.schemaname, PT.tablename\nFROM pg_publication_tables PT\n     JOIN pg_class C ON (C.relname = PT.tablename)\n     JOIN pg_namespace N ON (N.nspname = PT.schemaname),\n     pg_subscription_rel PS\nWHERE C.relnamespace = N.oid AND\n      (PS.srrelid = C.oid OR\n      C.oid IN (SELECT relid FROM pg_partition_ancestors(PS.srrelid) UNION\n                SELECT relid FROM pg_partition_tree(PS.srrelid))) AND\n      PT.pubname IN (\u0026lt;pub-names\u0026gt;);\n\u003c/pre\u003e","key":"notes","title":"注解"},{"html":"\u003cp\u003e创建一个指向远端服务器的订阅，复制发布 \u003ccode class=\"literal\"\u003emypublication\u003c/code\u003e和\u003ccode class=\"literal\"\u003einsert_only\u003c/code\u003e中的表，并在提交时立即开始复制：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE SUBSCRIPTION mysub\n         CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb'\n        PUBLICATION mypublication, insert_only;\n\u003c/pre\u003e\u003cp\u003e创建一个指向远端服务器的订阅，复制\u003ccode class=\"literal\"\u003einsert_only\u003c/code\u003e发布中的表，并且要等到稍后启用时才开始复制。\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE SUBSCRIPTION mysub\n         CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb'\n        PUBLICATION insert_only\n               WITH (enabled = false);\n\u003c/pre\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE SUBSCRIPTION\u003c/code\u003e是 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e扩展。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/alter-subscription/?v=18\" title=\"ALTER SUBSCRIPTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER SUBSCRIPTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-subscription/?v=18\" title=\"DROP SUBSCRIPTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP SUBSCRIPTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-publication/?v=18\" title=\"CREATE PUBLICATION\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE PUBLICATION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-publication/?v=18\" title=\"ALTER PUBLICATION\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER PUBLICATION\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"CREATE SUBSCRIPTION \u003cem class=\"replaceable\"\u003e\u003ccode\u003esubscription_name\u003c/code\u003e\u003c/em\u003e\n    CONNECTION '\u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e'\n    PUBLICATION \u003cem class=\"replaceable\"\u003e\u003ccode\u003epublication_name\u003c/code\u003e\u003c/em\u003e [, ...]\n    [ WITH ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003esubscription_parameter\u003c/code\u003e\u003c/em\u003e [= \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e] [, ... ] ) ]","synopsis_text":"CREATE SUBSCRIPTION subscription_name\nCONNECTION 'conninfo'\nPUBLICATION publication_name [, ...]\n[ WITH ( subscription_parameter [= value] [, ... ] ) ]"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
