▪ creating the publication that defines the replicated data set in the master database, see Creating publications.
The SQL statements that are needed to configure the master database are provided in the following sample script.
Sample script: master1.sql
If you are using the working directories and sample scripts in the samples\smartflow\ directory, go the solidDB installation root directory and run the following command:
▪ -O eval.out is an optional parameter that defines the output file for results,
▪ "tcp 1315" is the network protocol and address of the master database server. You might have to customize this part of the command,
▪ dba and dba_password are user name and password respectively,
▪ master1.sql is the executed SQL script.
You can view the results in eval.out with any text editor.
Note When you execute Advanced Replication scripts, you must set the autocommit mode to OFF. In solidDB SQL Editor (solsql), the autocommit mode is set to OFF by default.
--******************************************** -- master1.sql -- Execute this script in the MASTER database. -- Initializes the master with server name MASTER. -- Creates a table and publication. --******************************************** -- Create the catalog named "sync_demo_catalog". -- Give this server the name "master_server". -- Register this server as a master, and not as a replica. CALL SYNC_SETUP_CATALOG ( 'sync_demo_catalog', 'master_server', 1, 0); COMMIT WORK;
-- Set the catalog to be the current catalog. SET CATALOG sync_demo_catalog; COMMIT WORK;
-- Create the table that will be synchronized. CREATE TABLE SYNCDEMO ( REPLICAID INTEGER NOT NULL, ID INTEGER NOT NULL, STATUS INTEGER NOT NULL, INTDATA INTEGER, TEXTDATA CHAR(30), UPDATETIME TIMESTAMP, PRIMARY KEY (REPLICAID, ID, STATUS) ); --Enable syncronization history for the table ALTER TABLE SYNCDEMO SET SYNCHISTORY; COMMIT WORK;
-- Create a publication that publishes all data of the SYNCDEMO table. -- Note: CREATE PUBLICATION commands must be inside double quotation marks.
"CREATE PUBLICATION PUB_DEMO BEGIN RESULT SET FOR SYNCDEMO BEGIN SELECT * FROM SYNCDEMO ; END END"; COMMIT WORK;
The PUB_DEMO publication contains all the rows in the SYNCDEMO table. Refreshes from this publication will be incremental because the SYNCHISTORY property is set for this table in both the master and replica databases.