What is replication?
- SQL course
- Expert
- Lesson 24/45
- 5 min
Copy data to another server.
What is replication?
Replication copies data to multiple nodes. It provides read scaling and high availability. If one node fails, another takes over.
CREATE PUBLICATION pub_orders
FOR TABLE orders;Replication copies data.
The publication pub_orders is created.
What is replication? — details
The publisher publishes the table, the subscriber pulls copies. This is logical replication; in physical replication the whole database is copied block by block.
Practice What is replication?
Create the pub_orders publication for the orders table: CREATE PUBLICATION pub_orders FOR TABLE orders.
Starter code
-- replication
CREATE PUBLICATION pub_ordersSample solution
CREATE PUBLICATION pub_orders FOR TABLE orders;Expected output
CREATE PUBLICATION
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What does replication provide?
- Less disk space
- High availability Correct answer
- Faster writes
- Column compression
Explanation: Replication provides high availability.
2 Create a publication
CREATE PUBLICATION pub_orders FOR TABLE ____
CREATE PUBLICATION pub_orders FOR TABLE orders
Explanation: CREATE PUBLICATION … FOR TABLE orders publishes changes of the orders table to subscribers.
3 What is replication: match the terms
| Term | Meaning |
|---|---|
replication |
replication |
publisher |
publisher |
subscriber |
subscriber |
node |
node |