【问题标题】:Trouble exporting data from Redshift using PSQL使用 PSQL 从 Redshift 导出数据时遇到问题
【发布时间】:2016-11-14 12:23:07
【问题描述】:

我可以使用 psql 连接到 redshift。连接后,我将尝试运行以下命令:

copy (select * from *tablename* limit 10) to '/home/*path*/test.csv' with csv

我收到以下错误:

ERROR:  syntax error at or near "("

我无法弄清楚为什么会出现此错误。

我不确定是否需要复制到 s3 帐户?或者如果我能够直接从 redshift 复制到我的本地机器 - 这些 resource 1resource 2 似乎表明我需要一个 s3 帐户?

任何帮助将不胜感激!

【问题讨论】:

    标签: linux postgresql amazon-web-services amazon-redshift psql


    【解决方案1】:

    您似乎只能按照this documentation 将数据从 Amazon Redshift 导出到 S3。

    另一种方法似乎是,如果在 psql 中登录到 Redshift:

    =# \o *directory*/filename.csv
    =# *query*;
    =# \o
    

    这似乎将数据直接从 redshift 导出到我本地机器上的文件中。

    如果你想要一个未对齐的输出,你可以使用下面的

    =# \a \o *directory*/filename.csv
    =# *query*;
    =# \o
    

    我暂时不会将此标记为已回答,以防有更好的答案。

    【讨论】:

      猜你喜欢
      • 2020-07-17
      • 2020-11-19
      • 2019-08-25
      • 2016-04-21
      • 2020-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      相关资源
      最近更新 更多