Introducing SQL Anywhere Studio
Tutorial: Replicating Data with SQL Remote
Lesson 4: Replicate data
First, enter a row in the consolidated database.
Enter data in the consolidated database
Add a row into the department table.
In Sybase Central, open the Tables folder of the consolidated database (asademo), select the department table and click the Data tab in the right pane.
Click the plus sign in the toolbar to add a row. Enter the following values:
Column | Value |
---|---|
dept_id | 202 |
dept_name | Eastern Sales |
dept_head_id | Leave as (NULL) |
Press Enter. If a confirmation dialog appears, click Yes to update the row.
The next step is to send the new row to the remote database.
To send data to the remote database, you run the Message Agent at the consolidated database. The dbremote program is the Message Agent for Adaptive Server Anywhere.
Send the data to the remote database
At a command prompt, navigate to your tutorial directory. For example, navigate to c:\tutorial.
To run the Message Agent against the consolidated database, execute the following command:
dbremote -c "dbn=asademo;uid=DBA;pwd=SQL"
The SQL Remote window appears, and displays messages about the status of replication.
When SQL Remote displays the message Execution completed
, click Shutdown.
To receive the insert statement at the remote database, you must run the Message Agent, dbremote, at the remote database.
Receive data at the remote database
At a command prompt, change to your tutorial directory. For example, navigate to c:\tutorial.
Execute the following command to run the Message Agent against the field database:
dbremote -c "dbn=field;uid=field;pwd=field"
The SQL Remote window appears, informing you of the status of replication. The window indicates that a message was received from DBA.
When SQL Remote displays the message Execution completed
, click Shutdown.
The SQL Remote window displays status information while running. This information can be output to a log file for record keeping. You will see that the Message Agent first receives a message from asademo, and then sends a message. This return message contains confirmation of successful receipt of the replication update; such confirmations are part of the SQL Remote message tracking system that ensures message delivery even in the event of message system errors.
Depending on the current status of the database, there are three different connectivity parameters you can use to connect to a database:
dbf Connect to the database using the database file. This parameter requires you to specify the database file itself. If no server is currently running, a server will be started and the database will be loaded onto it. If a server is already running, the database will be loaded onto the default server.
dbn Connect to the database using the database name. This parameter requires you to specify the name of the database. You can only use this parameter when the database is already running.
dbs Connect to the database using the database source. A data source is a collection of parameters stored in the system registry or in a set of files. The source is referenced simply by its name.
For more information about data sources, see DataSourceName connection parameter [DSN].