pg_dump

用于备份单个 PostgreSQL 数据库的核心实用程序

pg_dump 是一个 核心实用程序,用于将单个 PostgreSQL 数据库备份为 SQL 脚本、TAR 档案或自定义档案文件。

pg_dump 一直存在于 PostgreSQL 中。

更改历史

开发中

示例

单个表的纯文本转储的示例输出(包括定义和内容)

$ pg_dump -Fp -d 'host=localhost dbname=app user=appuser' --table=app.language 
--
-- PostgreSQL database dump
--

-- Dumped from database version 12.5
-- Dumped by pg_dump version 14devel

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: language; Type: TABLE; Schema: app; Owner: appuser
--

CREATE TABLE app.language (
    lang_id character(2) NOT NULL,
    name_english character varying(64),
    name_native character varying(64),
    CONSTRAINT language_lang_id_check CHECK ((lang_id ~ '^[a-z]{2}$'::text))
);


ALTER TABLE app.language OWNER TO app;

--
-- Data for Name: language; Type: TABLE DATA; Schema: app; Owner: appuser
--

COPY app.language (lang_id, name_english, name_native) FROM stdin;
en      English English
de      German  Deutsch
ja      Japanese        日本語
th      Thai    ไทย
\.


--
-- Name: language language_pkey; Type: CONSTRAINT; Schema: app; Owner: appuser
--

ALTER TABLE ONLY app.language
    ADD CONSTRAINT language_pkey PRIMARY KEY (lang_id);

--
-- PostgreSQL database dump complete
--

分类

备份核心实用程序数据导入/导出

参见

pg_dumpallpg_restoretest_pg_dump

反馈

提交任何关于“pg_dump”的评论、建议或更正 此处