gpt4 book ai didi

amazon-redshift - 当表列包含保留关键字时,在 AWS Redshift 中使用 pg_dump 的表转储失败

转载 作者:行者123 更新时间:2023-12-04 02:03:00 25 4
gpt4 key购买 nike

我的目标是转储数据库中所有表的表结构,没有任何内容。

我有一些包含保留关键字的 Redshift 表。如果我尝试转储它们,则会出现此错误:

pg_dump -sc --quote-all-identifiers -h example.com -p 5439 -d redacted -U redacted --table public.mytable > ./blah.txt
pg_dump: [archiver (db)] query failed: ERROR: syntax error at or near "stdout"
LINE 1: ... "status", "date") TO stdout;
^
pg_dump: [archiver (db)] query was: COPY "public"."mytable" ("status", "date") TO stdout;

如果我尝试使用 pg_dump -sc --quote-all-identifiers -h example.com -p 5439 -d redacted -U redacted --table public.mytable > ./blah.txt 仅导出表结构然后命令成功,但生成的文件包含此 create table 语句:
CREATE TABLE "mytable" (
);

除了新行之外,括号内没有任何内容。

pg_dump 版本是 pg_dump (PostgreSQL) 9.5.8在 Ubuntu 16.04 上。

该问题影响了几个不同的表,这些表中的一个共同点是在 psql reserved words list 上有以单词命名的列。 .也许对为什么会发生这种情况还有另一种解释,所以我很想听听关于这个问题的其他理论。

虽然很好,但我无法更改表中列的名称。

最佳答案

强烈建议您不要使用 pg_dump对于 Redshift 。试试 UNLOAD命令代替。
https://docs.aws.amazon.com/redshift/latest/dg/r_UNLOAD.html

关于amazon-redshift - 当表列包含保留关键字时,在 AWS Redshift 中使用 pg_dump 的表转储失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46064740/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com