Creating a replicated database involves
creating the database and then associating it
with a replication set.
About this task
The following example illustrates the process. The example results
in the creation of table t1 in
database repl_test_db on the replica having contents identical
to that of the primary.
Procedure
- On the primary node, issue the
following:
nzsql
CREATE DATABASE repl_test_db replication set replset;
\c repl_test_db
CREATE TABLE t1 (i1 int, i2 int);
INSERT INTO t1 values (0,0);
INSERT INTO t1 values (1,1);
INSERT INTO t1 values (2,2);
- On the replica node, issue the following
commands. The replication_sync view verifies that
the nodes are synchronized.
nzsql
SELECT * FROM _v_replicated_database;
\c repl_test_db
SELECT * FROM t1;
SELECT * FROM _v_replication_sync