0
0
PostgreSQLquery~10 mins

Logical replication basics in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a publication for all tables.

PostgreSQL
CREATE PUBLICATION my_pub FOR [1];
Drag options to blanks, or click blank then click option'
Aall tables
Ball_tables
Call
Dtables
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'all' instead of 'all tables' causes syntax error.
Using 'all_tables' is not recognized.
2fill in blank
medium

Complete the code to create a subscription connecting to a publisher.

PostgreSQL
CREATE SUBSCRIPTION my_sub CONNECTION '[1]' PUBLICATION my_pub;
Drag options to blanks, or click blank then click option'
Alocalhost mydb replicator secret
Bhost=localhost dbname=mydb user=replicator password=secret
Cuser=replicator password=secret dbname=mydb host=localhost
Ddbname=mydb host=localhost user=replicator
Attempts:
3 left
💡 Hint
Common Mistakes
Using space-separated values without keys causes errors.
Missing password or user key causes connection failure.
3fill in blank
hard

Fix the error in the publication creation by choosing the correct option.

PostgreSQL
CREATE PUBLICATION my_pub FOR TABLE [1];
Drag options to blanks, or click blank then click option'
A(users, orders)
Busers orders
Cusers
Dusers, orders
Attempts:
3 left
💡 Hint
Common Mistakes
Using spaces instead of commas between table names.
Using parentheses causes syntax error.
4fill in blank
hard

Fill both blanks to create a publication for specific tables and enable insert replication.

PostgreSQL
CREATE PUBLICATION my_pub FOR TABLE [1] WITH (publish = '[2]');
Drag options to blanks, or click blank then click option'
Ausers, orders
Bupdate
Cinsert
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using spaces instead of commas between tables.
Using 'update' instead of 'insert' for insert replication.
5fill in blank
hard

Fill all three blanks to create a subscription with a connection string, publication, and enable copy data.

PostgreSQL
CREATE SUBSCRIPTION my_sub CONNECTION '[1]' PUBLICATION [2] WITH (copy_data = [3]);
Drag options to blanks, or click blank then click option'
Ahost=replica dbname=shop user=replicator password=pass123
Bmy_pub
Ctrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using incomplete connection strings.
Mismatching publication names.
Setting copy_data to false when data copy is needed.