퍼블리케이션 구성
복제할 테이블과 작업을 지정하도록 마스터 서버에서 퍼블리케이션을 정의하는 방법을 배웁니다.
퍼블리케이션 구성은(는) CoddyKit의 무료 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Advanced PostgreSQL: Indexing, Partitioning, Replication 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
What are Publications?
Welcome! In PostgreSQL logical replication, a publication is like a channel on the master server that broadcasts data changes.
It defines what data (which tables) and which operations (INSERTs, UPDATEs, DELETEs, TRUNCATEs) should be replicated to subscribing servers.
Think of it as setting up a TV station: you decide which shows to broadcast and when.
Basic Publication Setup
Creating a publication is straightforward using the CREATE PUBLICATION command. Let's start with the simplest form.
This creates a publication that doesn't publish any tables yet, but it's ready to be configured.
CREATE PUBLICATION my_first_pub;Publishing All Tables
If you want to replicate all tables in your current database (and any new ones created later), you can use the FOR ALL TABLES clause.
This is handy for replicating an entire database schema.
CREATE PUBLICATION all_db_changes FOR ALL TABLES;Publishing Specific Tables
Often, you only need to replicate a subset of tables. You can specify these tables directly using the FOR TABLE clause.
This publication will only broadcast changes from the users and products tables.
CREATE PUBLICATION sales_data_pub FOR TABLE users, products;Dynamic vs. Static
There's a key difference between FOR ALL TABLES and listing tables with FOR TABLE:
FOR ALL TABLES: Dynamically includes all current and future tables in the database.FOR TABLE table1, table2: Statically lists specific tables. New tables must be added manually.
Choose based on your replication needs!
Replicating Specific Operations
Publications can be configured to replicate only certain types of data modifications. By default, INSERT, UPDATE, DELETE, and TRUNCATE are replicated.
You can use the WITH (publish = '...') clause to select specific operations. Here, we only replicate INSERT statements.
CREATE PUBLICATION new_orders_only FOR TABLE orders WITH (publish = 'insert');Combining Operations
To replicate multiple, but not all, operation types, you can list them separated by commas within the publish option.
This publication will replicate INSERT, UPDATE, and DELETE operations, but not TRUNCATE.
CREATE PUBLICATION user_activity FOR TABLE user_logs WITH (publish = 'insert, update, delete');Listing Publications
Want to see what publications are active on your server? PostgreSQL stores this information in its system catalogs.
You can query the pg_publication view to get details about each publication, including what operations it publishes.
SELECT pubname, puballtables, pubinsert, pubupdate, pubdelete, pubtruncate FROM pg_publication;Managing Publications
You can modify an existing publication to add or remove tables, or even drop it entirely if it's no longer needed.
ALTER PUBLICATION ADD TABLE: Add tables.ALTER PUBLICATION DROP TABLE: Remove tables.DROP PUBLICATION: Delete a publication.
ALTER PUBLICATION sales_data_pub ADD TABLE accounts;
ALTER PUBLICATION sales_data_pub DROP TABLE products;
DROP PUBLICATION sales_data_pub;Publication Configuration Quiz
Which of the following statements correctly configure a publication in PostgreSQL?
Recap: Configuring Publications
Great job! You've learned how to define publications in PostgreSQL.
- Publications broadcast data changes for logical replication.
- Use
CREATE PUBLICATIONto define them. - You can publish
FOR ALL TABLESorFOR TABLE specific_tables. - The
WITH (publish = '...')clause lets you select specific operations (insert, update, delete, truncate). - You can manage them with
ALTER PUBLICATIONandDROP PUBLICATION.
Next, we'll learn how to set up subscriptions to receive these changes!
자주 묻는 질문
“퍼블리케이션 구성” 강의는 무료인가요?
네 — “퍼블리케이션 구성” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의 전체를 잠금 해제할 수 있습니다. Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에는 총 4개의 강의가 포함되어 있습니다.
“퍼블리케이션 구성”에서 뭘 배우나요?
복제할 테이블과 작업을 지정하도록 마스터 서버에서 퍼블리케이션을 정의하는 방법을 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 Advanced PostgreSQL: Indexing, Partitioning, Replication을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Advanced PostgreSQL: Indexing, Partitioning, Replication을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Advanced PostgreSQL: Indexing, Partitioning, Replication은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.
“퍼블리케이션 구성” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 논리적 복제 기초
- 퍼블리케이션 구성
- 구독 관리
- 논리 복제의 충돌 해결