pg_dump 输出空的创建语句

pg_dump outputs empty create statements

所以我正在尝试使用 pg_dump 从 Redshift 数据库中转储几个 table。我对这里的数据本身不感兴趣,将使用 UNLOAD 在单独的过程中提取这些数据。

然而,尽管 pg_dump 执行没有任何错误,但输出-sql-脚本中的 CREATE TABLE 语句是空的,例如我得到类似

的东西
CREATE TABLE test_data_sampling.orders();

有趣的是,接下来是

ALTER TABLE ONLY test_data_sampling.orders ALTER COLUMN orders_id SET NOT NULL;

这似乎表明 pg_dump 完全了解 table 中的至少一列。

我的 pg_dump 电话是这样的:

pg_dump -s -t test_data_sampling.customer -t test_data_sampling.orders -t test_data_sampling.addr --dbname=postgresql://<user>:<password>@<host>:<port>/dbName?ssl=true --file=backup_dbName.sql

当我使用在 pg_dump 调用中指定的相同用户登录数据库时,我可以毫无问题地查询 tables(即它们确实有列)。 我的用户是 table 的所有者以及架构的所有者。

我很茫然。任何帮助将不胜感激。

编辑: 一些附加信息。

有问题的 table 是

的产物
CREATE TABLE <table> (LIKE <parentTable>);

在订单的情况下,父级的 ddl 如下所示:

CREATE TABLE IF NOT EXISTS <parentTableName>(
    orders_id int primary key, 
    cust_id int, 
    item varchar(50), 
    order_date date, 
    descr varchar(100)
);

正如人们可能从这些 DDL 中猜测的那样,这些只是一些虚拟测试 tables。

有一个 view for generating table DDL in the Redshift Utils library on GitHub .

库中的其他项目也可用于提取现有项目。