简体   繁体   English

使用 SQL Workbench 将 csv 文件导入 AWS Redshift 数据库

[英]use SQL Workbench import csv file to AWS Redshift Database

I'm look for a manual and automatic way to use SQL Workbench to import/load a LOCAL csv file to a AWS Redshift database.我正在寻找一种手动和自动方式来使用 SQL Workbench 将本地 csv 文件导入/加载到 AWS Redshift 数据库。

The manual way could be a way that click a navigation bar and select a option.手动方式可以是单击导航栏并选择一个选项的方式。

The automatic way could be some query codes to load the data, just run it.自动方式可能是一些查询代码来加载数据,只需运行它。

here's my attempt: there's an error "my target table in AWS is not found."这是我的尝试:出现错误“我在 AWS 中的目标表未找到。” but I'm sure the table exists, anyone know why?但我确定该表存在,有人知道为什么吗?

WbImport -type=text
-file ='C:\myfile.csv'
-delimiter = ,
-table = public.data_table_in_AWS
-quoteChar=^
-continueOnError=true
-multiLine=true

You can use wbimport in SQL Workbench/J to import data可以在 SQL Workbench/J 中使用 wbimport 导入数据

For more info : http://www.sql-workbench.net/manual/command-import.html欲了解更多信息: http : //www.sql-workbench.net/manual/command-import.html

Like it was mentioned in the comments COPY command provided by Redshift is the optimal solution.就像评论中提到的那样,Redshift 提供的COPY命令是最佳解决方案。 You can use copy from S3, EC2 etc. S3 Example:您可以使用来自 S3、EC2 等的副本。 S3 示例:

copy <your_table>
from 's3://<bucket>/<file>'
access_key_id 'XXXX'
secret_access_key 'XXXX'
region '<your_region>'
delimiter '\t';

For more examples:更多示例:

https://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html https://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html

there's an error in my code below "my target table in AWS is not found." “找不到我的AWS中的目标表”下面的代码中有一个错误。 but I'm sure the table exists, anyone know why? 但我确定该表存在,有人知道为什么吗?

WbImport -type=text
-file ='C:\myfile.csv'
-delimiter = ,
-table = public.data_table_in_AWS
-quoteChar=^
-continueOnError=true
-multiLine=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM