Creating Publications and Articles at the Command Line

Learn how to use RCL commands to prepare a publication for subscription and create a subscription against it.

  1. At the source Replication Server:
    1. Create or select replication definitions for the tables or stored procedures from which you want to copy data.

      The replication definition specifies the source and destination tables or stored procedure and the columns or parameters that are sent to the subscribing database.

    2. Use create publication to create the publication that groups the replication definitions.

      Publication information is stored in the rs_publications system table in the source Replication Server RSSD. It includes the name of the publication, data server, and database. The publication name must be unique for the source Replication Server and database.

      The following example creates a publication named pubs2_pub. The primary database is pubs2 managed by the TOKYO_DS data server.
      create publication pubs2_pub
            with primary at TOKYO_DS.pubs2

      Publication information is not copied to the destination Replication Server until you create a subscription against the publication at the destination Replication Server.

      See Replication Server Reference Manual > Replication Server Commands for complete syntax and usage guidelines.

    3. Use create article to create articles for the publication.

      Each article specifies the publication to which it belongs and the table or function replication definition with which it identifies. A publication can contain articles based on the same or different replication definitions. The replication definition and publication must exist when you create the article.

      An article includes the names of the publication, the replication definition, and the source data server and database. Article information is stored in the rs_articles and rs_whereclauses system tables. Each article name must be unique within the publication.

      The following example creates an article named titles_art based on the replication definition titles_rep for the publication pubs2_pub.
      create article titles_art
          for pubs2_pub with primary at TOKYO_DS.pubs2
          with replication definition titles_rep

      An article can include where clauses that specify the rows or parameters to be sent to subscribing databases.

      Creating an article invalidates the publication, which makes it ineligible for subscription. After you create an article, you must change the status of the publication to VALID, using validate publication, before you can create subscriptions against it.

      See Replication Server Reference Manual > Replication Server Commands for complete syntax and usage guidelines.

    4. Use validate publication to change the status of the publication to VALID.

      When you validate a publication, Replication Server checks that the publication contains at least one article and marks the publication ready for subscription.

      Whenever you add or drop an article from a publication, Replication Server invalidates the publication. To mark the publication VALID—and ready for subscription—you must execute validate publication.

      After you validate a publication, you can create a publication subscription against it.

      The following example validates the pubs2_pub publication. The source database is pubs2 managed by the TOKYO_DS data server.
      validate publication pubs2_pub
      			with primary at TOKYO_DS.pubs2

      See Replication Server Reference Manual > Replication Server Commands for complete syntax and usage guidelines.

  2. At the destination Replication Server:
    1. Use create subscription to create the publication subscription.

      When you create a publication subscription, Replication Server creates a subscription for each article in the publication.

Related concepts
Create Replication Definitions
Specifying a where Clause with the create article Command
Publication Subscriptions