Lesson 3: Creating publications and subscriptions

A publication describes the set of data to be replicated. In this lesson you create a publication named SalesRepData that replicates all rows of the SalesReps table, and some rows of the Customers table. You subscribe a user to a publication by creating a subscription.

 Create the publication on the consolidated database (Interactive SQL)
  1. If you are not currently connected to the consolidated database (hq), run the following command:

    dbisql -c "UID=DBA;PWD=sql;SERVER=server_hq;DBF=c:\tutorial\hq.db"
  2. Execute the following statement to create a publication named SalesRepData:

    CREATE PUBLICATION SalesRepData (
     TABLE SalesReps,
     TABLE Customers SUBSCRIBE BY rep_key
    );

    The SalesRepData publication publishes:

    • The entire SalesReps table

    • All of the columns in the Customers table but only the rows that match a specified rep_key value

  3. Execute the following statement to create a subscription to SalesRepData:

    CREATE SUBSCRIPTION
    TO SalesRepData ('rep1')
    FOR field_user;

    The value rep1 is the rep_key value for the user Field User in the SalesReps table.

    Note

    In this tutorial, there is no protection against duplicate entries of primary key values. For information, see Creating SQL Remote systems.