Using the create subscription command

Use create subscription to create a publication subscription and an article subscription for each article in the publication. You can use create subscription to materialize source data at the destination database using the atomic, nonatomic, or no-materialization method.

Execute create subscription at the Replication Server that manages the destination database. Subscription information is stored in the rs_subscriptions system tables at the primary and replicate sites.

The following example creates a subscription named pubs2_sub for the publication pubs2_pub. It also creates a subscription named pubs2_sub for each article in pubs2_pub. The source database is pubs2 managed by the TOKYO_DS data server. The destination database is also named pubs2; it is managed by the SYDNEY_DS data server.

create subscription pubs2_sub 
		for publication
		with primary at TOKYO_DS.pubs2
		with replicate at SYDNEY_DS.pubs2

NoteThe maximum size of a where clause in a create subscription statement is 255 characters.

Refer to Chapter 3, “Replication Server Commands,” in the Replication Server Reference Manual for complete syntax and usage guidelines.


Specifying a materialization method

Specify materialization methods for publication subscriptions in the same way you specify materialization methods for regular subscriptions. When you use create subscription, you can specify atomic, nonatomic, or the no-materialization method. The default method is atomic materialization, using the select with holdlock operation.

Article subscriptions share the name of the parent subscription and generally, its materialization method. However, function replication definitions require the bulk or no-materialization method. If you use create subscription, and articles in the publication reference function replication definitions, Replication Server uses the no-materialization method for these article subscriptions—regardless of the materialization method specified in the publication subscription.

See “Subscription materialization methods” for a description of the different materialization methods.


Refreshing publication subscriptions

When you add articles to an existing publication, you must add article subscriptions to the existing publication subscription to subscribe to the new articles. Use for new articles to refresh the subscription. This clause instructs Replication Server to check the subscription against the publication and then to create subscriptions for any unsubscribed articles.

For example, to refresh the publication subscription pubs2_sub, enter this command at the destination Replication Server:

create subscription sub for publication pub
		with primary at TOKYO_DS.pubs2
		with replicate at SYDNEY_DS.pubs2
		for new articles

Use check subscription to find out whether a subscription exists for each article in a publication. See “Displaying status information” for more information about check subscription.