Skip to content

Specialist format guide

SQL Dump Structure and Sensitive Field Review: Inspect Before Restore

Review SQL dump structure, executable statements, schemas, COPY sections, ownership metadata, and sensitive-field boundaries before a dump is restored or shared.

A SQL dump is not just a text export. It can contain schema definitions, data statements, COPY sections, functions, triggers, roles, ownership, grants, extensions, search-path changes, and comments. PostgreSQL documents that restoring a dump executes commands from the source, so inspect a dump as text or a controlled parse artifact before any restore. This guide is a structural and sensitivity worksheet, not a restore service, security audit, privacy decision, or permission claim. Source dates shown here are documentation retrieval dates, checked 22 October 2026; original publication dates are not established.

Updated

On this page

Identify the dump boundary and format first

Record a neutral artifact ID, digest, producer command if available, PostgreSQL version, dump format, encoding, and whether the artifact is plain SQL, a directory archive, or another archive format. Do not execute an untrusted dump just to learn its shape. PostgreSQL’s PostgreSQL Global Development Group, (opens in a new tab) documentation distinguishes output formats and explains that a plain script contains SQL commands required to reconstruct the database.

Identify the dump boundary and format first (table)
Boundary fieldRecordStop if
Artifact identityNeutral ID and digestDerivative cannot be matched to source
Dump formatPlain, custom, directory, tar, or unknownReader assumptions replace source declaration
EncodingDeclared or observed encodingText is decoded with a fallback
Producer contextTool, version, options if knownVersion is guessed from syntax
Restore modeNever run, dry plan, or controlled runRestore is the only inspection method
ScopeSchemas, tables, extensions, roles, or unknownScope is inferred from a filename

Keep an archive listing or statement inventory separate from the source. If an archive contains paths, comments, or metadata that disclose private context, redact the report rather than changing the source artifact.

Inventory executable statements before reading rows

Classify statement families without executing them. Include CREATE, ALTER, DROP, SET, GRANT, REVOKE, COMMENT, CREATE FUNCTION, DO blocks, extension installation, ownership changes, triggers, and search-path changes. A text scanner can miss nested dollar-quoted strings or comments, so label the inventory method and retain an unresolved state where the parser boundary is uncertain.

Inventory executable statements before reading rows (table)
Statement familyRecordDecision boundary
Schema definitionsSchemas, tables, types, views, sequencesStructure only, not data quality
IndexesCREATE INDEX statements, target, keys or expressions, method, predicateAssuming CREATE TABLE inventories ordinary indexes
Data loadingCOPY targets, INSERT targets, row count if declaredSensitive fields need classification
Execution hooksFunctions, DO, triggers, event hooksDo not execute for inspection
Access stateOwners, grants, default privilegesNot a substitute for current access review
Environment changesSET search_path, role, extension, session settingsRestore behavior can vary by environment
Comments and labelsPresence and redacted contextFree text may reveal private information

Synthetic statement inventory

Inventory executable statements before reading rows code example, Plain text
CREATE TABLE fixture_record (id text, note text);
CREATE INDEX fixture_record_id_idx ON fixture_record (id);
COPY fixture_record (id, note) FROM STDIN;
fixture-id-001\tfixture-note
\.
-- data omitted; do not execute this fixture

The fixture contains a structural COPY boundary but no real value. Record the target table and column list even when the rows are withheld. The PostgreSQL Global Development Group, (opens in a new tab) documentation describes COPY’s table and stream boundary; it does not make a particular dump safe to restore.

Compare schema structure with sensitive-field boundaries

Use CREATE TABLE statements to inventory column names, types, defaults, generated expressions, constraints, and partitioning. Inventory ordinary CREATE INDEX statements separately, including their target, keys or expressions, method, predicate, and name; the PostgreSQL Global Development Group, (opens in a new tab) page documents that boundary. The PostgreSQL Global Development Group, (opens in a new tab) page documents table structure, but a table definition does not by itself inventory every separately declared index. A field name can be misleading, so classify by producer definition and handling boundary rather than by a keyword alone.

Compare schema structure with sensitive-field boundaries (table)
Field reviewRecordDo not infer
Identifier-like columnsName, type, key role, transformationThat an ID is non-sensitive
Free textColumn, length, sample withheld stateThat comments or notes are empty
Dates and locationsType, resolution, timezone, scopeThat coarse values are harmless
Secrets and credentialsColumn or setting presence, no valuesThat redaction is complete without evidence
Defaults and generated valuesExpression and dependencyThat a value was stored directly
Constraints and referencesKey relationships and missing targetsThat constraints prove row correctness

Use metadata-only or synthetic fixtures to exercise this classification. Never paste a real row into a public guide worksheet. Keep a sensitive-field finding separate from any conclusion about use, ownership, or permission.

Reconcile structure without performing a restore

Compare the statement inventory, archive listing, table manifest, expected schema, and any declared row or object counts. If a controlled environment is later used, record its version and isolation boundary. A successful restore only shows that commands ran in that environment; it does not prove that the dump is complete, safe for another environment, or free of sensitive content.

Reconcile structure without performing a restore (table)
FindingDispositionNext action
Expected schema matches statementsConditionalClassify data and executable boundaries
COPY target is missing from schemaHoldResolve ordering or scope mismatch
Function or DO block appearsHoldInspect as code; do not execute for review
Owner, ACL, or search path differsHoldRecord environment-specific behavior
Sensitive field classification incompleteDo not sampleKeep values withheld and ask owner question
Declared counts disagreeHoldReconcile without treating count as quality

Stop conditions

  • Stop if the dump format, encoding, or statement boundary is unknown.
  • Stop if COPY, INSERT, functions, DO blocks, ownership, ACL, extension, or search-path behavior is unreviewed.
  • Stop if schema statements and data targets cannot be reconciled without executing the dump.
  • Stop if sensitive fields, free text, credentials, or comments are not classified at field level.
  • Stop before restoring an untrusted dump or sharing it when handling authority is unknown.

Keep the SQL next step qualified

Keep the artifact digest, format inventory, statement families, schema worksheet, sensitive-field boundary, reader version, and unresolved questions together. Pair this guide with the data provenance log for source and transformation history and the data card template for collection context. SQL structure is not a quality, privacy, rights, or ownership certificate.

For a supported non-health collection, after the owner has authority to describe the scope and a controlled metadata packet, the qualified appraisal request path may be a preparation step. It does not restore SQL dumps, execute statements, classify private values, create a quote, match a buyer, issue a legal opinion, or grant a license.

Takeaways

  • Identify format and encoding before classifying statements.
  • Inventory executable families and COPY targets without executing the source.
  • Use CREATE TABLE structure for table fields and constraints, and inventory CREATE INDEX statements separately.
  • Keep restore evidence, privacy review, rights review, and data-quality review separate.

Sources

  1. PostgreSQL Global Development Group: PostgreSQL: Documentation: 18: pg_dump (opens in a new tab)
  2. PostgreSQL Global Development Group: PostgreSQL: Documentation: 18: COPY (opens in a new tab)
  3. PostgreSQL Global Development Group: PostgreSQL: Documentation: 18: CREATE TABLE (opens in a new tab)
  4. PostgreSQL Global Development Group: PostgreSQL: Documentation: 18: CREATE INDEX (opens in a new tab)

Use the appraisal path after the SQL dump review packet is organized.

It does not restore SQL dumps, execute statements, classify private values, create a quote, match a buyer, or grant a license.