forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
57 lines
9.2 KiB
HTML
57 lines
9.2 KiB
HTML
<a name="EN-US_TOPIC_0000001510520997"></a><a name="EN-US_TOPIC_0000001510520997"></a>
|
|
|
|
<h1 class="topictitle1">CREATE SUBSCRIPTION</h1>
|
|
<div id="body0000001491993993"><div class="section" id="EN-US_TOPIC_0000001510520997__sf337ecb5bde84580afed94be7bbf5fb9"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001510520997__p11941336171015">Adds a new subscription to the current database. The subscription name must be different from a name of any existing subscription in the database. A subscription represents a replication for connecting to the publication side.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510520997__section93413620440"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001510520997__ul10234635104412"><li id="EN-US_TOPIC_0000001510520997__li85791254770">This statement is supported by clusters of version 8.2.0.100 or later.</li><li id="EN-US_TOPIC_0000001510520997__li146841404712">A subscription can be created only by the system administrator.</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510520997__s432427bf362e4684b4559ac16cfcda57"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510520997__s18d476418c7748ada6302a1c75028d5d"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span>
|
|
<span class="normal">3</span>
|
|
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="n">SUBSCRIPTION</span><span class="w"> </span><span class="n">name</span>
|
|
<span class="w"> </span><span class="k">CONNECTION</span><span class="w"> </span><span class="s1">'conninfo'</span>
|
|
<span class="w"> </span><span class="n">PUBLICATION</span><span class="w"> </span><span class="n">publication_name</span><span class="w"> </span><span class="p">[,</span><span class="w"> </span><span class="p">...]</span>
|
|
<span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">WITH</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">subscription_parameter</span><span class="w"> </span><span class="p">[</span><span class="o">=</span><span class="w"> </span><span class="n">value</span><span class="p">]</span><span class="w"> </span><span class="p">[,</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">]</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510520997__section1549681213574"><a name="EN-US_TOPIC_0000001510520997__section1549681213574"></a><a name="section1549681213574"></a><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001510520997__ul849711245713"><li id="EN-US_TOPIC_0000001510520997__li11885054185912"><strong id="EN-US_TOPIC_0000001510520997__b614481895914">name</strong><p id="EN-US_TOPIC_0000001510520997__p836651861419">Specifies the name of a subscription.</p>
|
|
<p id="EN-US_TOPIC_0000001510520997__p967943011145">Value range: A string. It must comply with the naming convention.</p>
|
|
</li><li id="EN-US_TOPIC_0000001510520997__li17392131613264"><a name="EN-US_TOPIC_0000001510520997__li17392131613264"></a><a name="li17392131613264"></a><strong id="EN-US_TOPIC_0000001510520997__b666192015277">conninfo</strong><p id="EN-US_TOPIC_0000001510520997__p2039210167263">Specifies the string for connecting to the publication side.</p>
|
|
<p id="EN-US_TOPIC_0000001510520997__p7389171161719">Example: <strong id="EN-US_TOPIC_0000001510520997__b663614153214">host=1.1.1.1,2.2.2.2 port=10000,20000 dbname=postgres user=repusr1 password=password_123</strong></p>
|
|
<ul id="EN-US_TOPIC_0000001510520997__ul11694623171619"><li id="EN-US_TOPIC_0000001510520997__li1969462351617"><strong id="EN-US_TOPIC_0000001510520997__b369452314160">host</strong><p id="EN-US_TOPIC_0000001510520997__p11694142301620">IP address of the publication side. You can specify the IP addresses of both the primary and standby nodes of the publication side. Separate the IP addresses with commas (,).</p>
|
|
</li><li id="EN-US_TOPIC_0000001510520997__li169492321613"><strong id="EN-US_TOPIC_0000001510520997__b76941323161619">port</strong><p id="EN-US_TOPIC_0000001510520997__p10694172314160">The publication port cannot be the primary port. Instead, it must be the primary port number plus 1. Otherwise, the port number conflicts with the thread pool. You can specify the ports of both the primary and standby nodes of the publication side. Separate the ports with commas (,).</p>
|
|
<div class="caution" id="EN-US_TOPIC_0000001510520997__note1425931131715"><span class="cautiontitle"><img src="public_sys-resources/caution_3.0-en-us.png"> </span><div class="cautionbody"><p id="EN-US_TOPIC_0000001510520997__p02592116176">The number of hosts must be the same as that of ports.</p>
|
|
</div></div>
|
|
</li><li id="EN-US_TOPIC_0000001510520997__li15694142391615"><strong id="EN-US_TOPIC_0000001510520997__b20694823191610">dbname</strong><p id="EN-US_TOPIC_0000001510520997__p196940233163">Specifies the database where a publication is deployed.</p>
|
|
</li><li id="EN-US_TOPIC_0000001510520997__li469442311612"><strong id="EN-US_TOPIC_0000001510520997__b17264830271">user</strong> and <strong id="EN-US_TOPIC_0000001510520997__b148614241715">password</strong><p id="EN-US_TOPIC_0000001510520997__p15694323151612">Specifies the username and password used to connect to the publication side. The user has the system administrator permission (<strong id="EN-US_TOPIC_0000001510520997__b1517198222101814">SYSADMIN</strong>) or O&M administrator permission (<strong id="EN-US_TOPIC_0000001510520997__b1865983638101814">OPRADMIN</strong>).</p>
|
|
</li></ul>
|
|
</li><li id="EN-US_TOPIC_0000001510520997__li98471129180"><strong id="EN-US_TOPIC_0000001510520997__b198475128185">publication_name</strong><p id="EN-US_TOPIC_0000001510520997__p384741231810">Specifies the name of the publication you want to subscribe to on the publication side. A subscription corresponds to multiple publications.</p>
|
|
</li><li id="EN-US_TOPIC_0000001510520997__li16847141212189"><strong id="EN-US_TOPIC_0000001510520997__b584821291811">WITH ( subscription_parameter [= value] [, ... ] )</strong><p id="EN-US_TOPIC_0000001510520997__p1284871211819">Specifies the optional parameters for a subscription. The following parameters are supported:</p>
|
|
<ul id="EN-US_TOPIC_0000001510520997__ul158482125185"><li id="EN-US_TOPIC_0000001510520997__li128481912101813"><strong id="EN-US_TOPIC_0000001510520997__b1184801218188">enabled</strong><p id="EN-US_TOPIC_0000001510520997__p52401629174217">Specifies whether a subscription should be actively replicated, or whether it should be just set but not started.</p>
|
|
<p id="EN-US_TOPIC_0000001510520997__p128321951184214">The value can be <strong id="EN-US_TOPIC_0000001510520997__b2099316362101814">true</strong> or <strong id="EN-US_TOPIC_0000001510520997__b66312516101814">false</strong>.</p>
|
|
<p id="EN-US_TOPIC_0000001510520997__p118481712121815">The default value is <strong id="EN-US_TOPIC_0000001510520997__b1949268790101814">true</strong>.</p>
|
|
</li><li id="EN-US_TOPIC_0000001510520997__li1841851593620"><strong id="EN-US_TOPIC_0000001510520997__b12848912121819">create_slot</strong><p id="EN-US_TOPIC_0000001510520997__p14848712191813">Specifies whether a replication slot is created on the publisher.</p>
|
|
<p id="EN-US_TOPIC_0000001510520997__p58934116417">The value can be <strong id="EN-US_TOPIC_0000001510520997__b279382801101814">true</strong> or <strong id="EN-US_TOPIC_0000001510520997__b1263407254101814">false</strong>.</p>
|
|
<p id="EN-US_TOPIC_0000001510520997__p104181415183619">The default value is <strong id="EN-US_TOPIC_0000001510520997__b1478591537101814">true</strong>.</p>
|
|
</li><li id="EN-US_TOPIC_0000001510520997__li5720141613613"><strong id="EN-US_TOPIC_0000001510520997__b137203166364">slot_name</strong><p id="EN-US_TOPIC_0000001510520997__p5720141683620">Specifies the name of the replication slot.</p>
|
|
<p id="EN-US_TOPIC_0000001510520997__p672015165365">Value range: a string</p>
|
|
<p id="EN-US_TOPIC_0000001510520997__p18720141673619">Default value: the subscription name</p>
|
|
</li></ul>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510520997__section1853433744413"><h4 class="sectiontitle">Examples</h4><div class="p" id="EN-US_TOPIC_0000001510520997__p1567918417167">Create a subscription to tables of the publication <strong id="EN-US_TOPIC_0000001510520997__b12607198141911">mypublication</strong> on a remote server.<pre class="screen" id="EN-US_TOPIC_0000001510520997__screen52415585211">CREATE SUBSCRIPTION mysub
|
|
CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb password=xxxx'
|
|
PUBLICATION mypublication;</pre>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510520997__s7408f0450b9b4dc7948c069376053290"><h4 class="sectiontitle">Helpful Links</h4><p id="EN-US_TOPIC_0000001510520997__en-us_topic_0059778825_p749627459"><a href="dws_06_0287.html">ALTER SUBSCRIPTION</a> <a href="dws_06_0289.html">DROP SUBSCRIPTION</a></p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0118.html">DDL Syntax</a></div>
|
|
</div>
|
|
</div>
|
|
|