给定以下 Postgres 容器:
docker run -i -p 54350:5432 --name test_postgres -e POSTGRES_PASSWORD=password -e POSTGRES_DB=test -e POSTGRES_SCHEMA=dba postgres:11 "-clog_statement=all"
和以下初始化 sql 脚本:
CREATE SCHEMA IF NOT EXISTS dba;
CREATE TABLE dba.mytable (mytable_id SERIAL);
运行时我得到\dt
:psql
psql -U postgres -h localhost -p 54350 -d test
test=# \dt dba.mytable
List of relations
Schema | Name | Type | Owner
--------+---------------+-------+----------
dba | mytable | table | postgres
(1 row)
test=#
但是当我尝试运行时pg_dump
,我得到以下信息:
pg_dump \
--username=postgres --host=localhost --port=54350 --dbname=test \
--schema-only \
--no-privileges \
--disable-triggers \
--no-publications \
--no-security-labels \
--no-subscriptions \
--no-synchronized-snapshots \
--quote-all-identifiers \
-t=dba.mytable > dump.sql
Password:
pg_dump: error: no matching tables were found
我也试过-t='"dba.mytable"'
和-t="dba.mytable"
。
我也试过-t=test.dba.mytable
,-t='"test.dba.mytable"'
和-t="test.dba.mytable"
, 但后来我明白了
pg_dump: error: cross-database references are not implemented: test.dba
如果我添加--schema=dba
我得到:
pg_dump: error: no matching schemas were found
你能帮我修复我的 pg_dump 命令以便允许我转储表吗dba.mytable
?
谢谢!