pg-dump Reference

Guide pgschema SQL queries using pg_dump's system catalog patterns.

322|45|Updated Dec 1, 2025
One-click install
npx skills add https://github.com/Microck/ordinary-claude-skills --skill pg-dump-reference
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pg-dump Reference
Source: https://github.com/Microck/ordinary-claude-skills/tree/main/skills_all/pg-dump-reference
Command: npx skills add https://github.com/Microck/ordinary-claude-skills --skill pg-dump-reference

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides guidance on using PostgreSQL's pg_dump for schema extraction and system catalog queries when implementing pgschema features.

Core Features & Use Cases

  • Guidance on relevant system catalogs and pg_dump patterns
  • Reference locations for PostgreSQL objects and dependencies

Quick Start

Use pg_dump reference patterns to extract the schema for a given database.

Frequently Asked Questions about pg-dump Reference

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract a PostgreSQL database schema using pg_dump?

Schema extraction with pg_dump reads PostgreSQL system catalogs to generate DDL statements. pg_dump queries pg_class, pg_attribute, pg_type, and pg_constraint tables to identify objects, their definitions, and dependencies, then outputs CREATE statements in dependency order.

What system catalog tables does pg_dump use to identify database objects?

pg_dump queries pg_class for tables and indexes, pg_attribute for columns, pg_type for data types, pg_constraint for constraints, pg_proc for functions, pg_trigger for triggers, pg_depend for dependencies, and pg_description for comments to reconstruct the complete schema.

How do I handle version-specific PostgreSQL features when extracting schema?

Different PostgreSQL versions (14–17) have variations in system catalog structure and object support. Reference pg_dump's version-aware logic in pg_dump.c and pg_dump_sort.c to conditionally query catalogs and format DDL based on the target PostgreSQL version.

Can I use pg_dump patterns to debug schema introspection queries?

Yes. pg_dump's main implementation files (pg_dump.c, pg_dump.h, pg_backup_archiver.c, common.c) demonstrate correct system catalog queries and DDL formatting. Study these patterns to validate and fix schema extraction logic in tools like pgschema's ir/inspector.go.

How are object dependencies resolved when generating DDL with pg_dump?

pg_dump queries pg_depend to map object relationships and uses pg_dump_sort.c logic to order DDL statements so dependencies are created before dependents, ensuring clean schema recreation without constraint or reference violations.

What's the difference between schema extraction and full database backup with pg_dump?

Schema-only extraction uses pg_dump's schema query patterns to generate DDL for tables, functions, and constraints without data. Full backup includes schema plus row data. Both use the same system catalog queries; schema mode filters out data export steps.