CTAS stops replication if 'WITH DATA' is used (and source is not empty).
0) create
directories and two databases (master & replica):
=========
$(dir_sampleDb)/qa_replication/
$(dir_sampleDb)/qa_replication/db_main.journal/
$(dir_sampleDb)/qa_replication/db_main.archive/
$(dir_sampleDb)/qa_replication/db_main.fdb
$(dir_sampleDb)/qa_replication/db_repl.fdb
=========
(in my case "
$(dir_sampleDb)" = C:\FB\60SS\EXAMPLES\EMPBUILD\ )
1) connect to master DB and run:
alter database enable publication;
alter database include all to publication;
2) prepare replication.conf:
=========
database
{
verbose_logging = true
}
database = $(dir_sampleDb)/qa_replication/db_main.fdb
{
journal_directory = "$(dir_sampleDb)/qa_replication/db_main.journal"
journal_archive_directory = "$(dir_sampleDb)/qa_replication/db_main.archive"
}
database = $(dir_sampleDb)/qa_replication/db_repl.fdb
{
journal_source_directory = "$(dir_sampleDb)/qa_replication/db_main.archive"
}
=========
(restart FB after this step)
3) add two aliases:
=========
db_main_alias = $(dir_sampleDb)/qa_replication/db_main.fdb
db_repl_alias = $(dir_sampleDb)/qa_replication/db_repl.fdb
=========
4) connect to master DB and run script:
=========
create table tbase(id int primary key, f01 int);
insert into tbase(id, f01) select row_number()over(), rand()*100 from rdb$types;
commit;
create table ctas_test as (select * from tbase) WITH DATA;
commit;
delete from ctas_test order by id rows 10;
commit;
=========
After short time replication.log will be fulfilled with:
=========
PZ (replica) Sat Jul 18 02:28:40 2026
Database: C:\FB\60SS\EXAMPLES\EMPBUILD\QA_REPLICATION\DB_REPL.FDB
ERROR: Table "PUBLIC"."CTAS_TEST" has no unique key
At segment 4, offset 48
PZ (replica) Sat Jul 18 02:28:40 2026
Database: C:\FB\60SS\EXAMPLES\EMPBUILD\QA_REPLICATION\DB_REPL.FDB
VERBOSE: Disconnecting and suspending
=========