将当前的 Redshift 架构导入 Redshift QA 环境

Import current Redshift schema to Redshift QA environment

我想将我当前的 Redshift DB 方案 table 结构导出到另一个 redshift DB 环境。

架构将存储在我的 S3 存储桶中,我想将没有任何数据的相同架构 table 结构从生产环境移动到我的测试 redshift 环境。导致两个环境具有相同的结构。

我发现 AWS 文档建议通过 S3 存储桶使用 UNLOAD 命令:我将如何在不复制不需要的数据的情况下执行此操作
https://docs.aws.amazon.com/redshift/latest/dg/r_UNLOAD.html

在没有数据的情况下导出当前 Redshift 架构 tables 并将其导入到另一个 Redshift 集群的最佳做法是什么?

您可以使用 Redshift Utils on GitHub. In particular you can use v_generate_tbl_ddl 中提供的 AdminViews 为现有表生成 DDL。

您可以使用以下命令为现有 table 生成 DDL 命令并使用该命令,您将能够在其他地方使用相同的架构重新创建 table。

select ddl from v_generate_tbl_ddl where schemaname = 'public' and tablename='product_description' order by seq asc;

product_description 替换为您的 table 名称,您将获得 table.

的 DDL 命令