我正在使用
pg_dump
(15.3) 将信息转储到数据库中。
此命令有效:
pg_dump --schema-only --schema foo -d foodb -U postgres -Fp
并转储 CREATE SCHEMA foo;
声明
此命令不会:
pg_dump --schema-only --schema cron -d foodb -U postgres -Fp
因为它只转储以下内容:
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;
--
-- PostgreSQL database dump complete
--
请注意,它不会抱怨架构不存在。
SELECT a.* FROM information_schema.schemata a where schema_name in ('foo','cron');
显示两个模式的相同输出(除了
schema_name
)
我正在使用 Docker 的 timescaledb (timescale/timescaledb-ha:pg15.3-ts2.11.0-all) 如果这有任何帮助
如果您的 pg_dump 没有转储 cron 架构,请尝试运行此命令;
pg_dump --schema=cron -d yourdatabase -U postgres -Fp -f cron_schema_dump.sql
将您的数据库替换为您实际数据库的名称。