博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AWS redshift->hdb pg(Greenplum),数据库-S3导入导出(unload, external table) - hdb pg external table...
阅读量:6407 次
发布时间:2019-06-23

本文共 2960 字,大约阅读时间需要 9 分钟。

背景

REDSHIFT通过unload将数据从REDSHIFT QUERY结果将数据导出到S3,通过EXTERNAL TABLE将数据从S3导入到REDSHIFT。

redshift unload 将QUERY结果导出到s3

UNLOAD ('select-statement')

TO 's3://object-path/name-prefix'
authorization
[ option [ ... ] ]

where option is

{ MANIFEST [ VERBOSE ]

| HEADER
| DELIMITER [ AS ] 'delimiter-char'
| FIXEDWIDTH [ AS ] 'fixedwidth-spec' }
| ENCRYPTED
| BZIP2
| GZIP
| ADDQUOTES
| NULL [ AS ] 'null-string'
| ESCAPE
| ALLOWOVERWRITE
| PARALLEL [ { ON | TRUE } | { OFF | FALSE } ]
[ MAXFILESIZE [AS] max-size [ MB | GB ] ]
redshift 使用EXTERNAL TABLE读取s3数据

CREATE EXTERNAL TABLE

external_schema.table_name
(column_name data_type [, …] )
[ PARTITIONED BY (col_name data_type [, … ] )]
[ { ROW FORMAT DELIMITED row_format |
ROW FORMAT SERDE 'serde_name'
[ WITH SERDEPROPERTIES ( 'property_name' = 'property_value' [, ...] ) ] } ]
STORED AS file_format
LOCATION { 's3://bucket/folder/' | 's3://bucket/manifest_file' }
[ TABLE PROPERTIES ( 'property_name'='property_value' [, ...] ) ]
阿里云hdb pg 使用EXTERNAL TABLE读取OSS数据、将数据导出到OSS
阿里云hdb pg 使用EXTERNAL TABLE读取OSS数据、将数据导出到OSS。

没有UNLOAD命令。

创建命令为:CREATE EXTENSION IF NOT EXISTS oss_ext;

删除命令为:DROP EXTENSION IF EXISTS oss_ext;

CREATE [READABLE] EXTERNAL TABLE tablename

( columnname datatype [, ...] | LIKE othertable )
LOCATION ('ossprotocol')
FORMAT 'TEXT'

[( [HEADER]             [DELIMITER [AS] 'delimiter' | 'OFF']             [NULL [AS] 'null string']             [ESCAPE [AS] 'escape' | 'OFF']             [NEWLINE [ AS ] 'LF' | 'CR' | 'CRLF']             [FILL MISSING FIELDS] )]         | 'CSV'          [( [HEADER]             [QUOTE [AS] 'quote']             [DELIMITER [AS] 'delimiter']             [NULL [AS] 'null string']             [FORCE NOT NULL column [, ...]]             [ESCAPE [AS] 'escape']             [NEWLINE [ AS ] 'LF' | 'CR' | 'CRLF']             [FILL MISSING FIELDS] )]

[ ENCODING 'encoding' ]

[ [LOG ERRORS [INTO error_table]] SEGMENT REJECT LIMIT count

[ROWS | PERCENT] ]

CREATE WRITABLE EXTERNAL TABLE table_name

( column_name data_type [, ...] | LIKE other_table )
LOCATION ('ossprotocol')
FORMAT 'TEXT'

[( [DELIMITER [AS] 'delimiter']             [NULL [AS] 'null string']             [ESCAPE [AS] 'escape' | 'OFF'] )]        | 'CSV'             [([QUOTE [AS] 'quote']             [DELIMITER [AS] 'delimiter']             [NULL [AS] 'null string']             [FORCE QUOTE column [, ...]] ]             [ESCAPE [AS] 'escape'] )]

[ ENCODING 'encoding' ]

[ DISTRIBUTED BY (column, [ ... ] ) | DISTRIBUTED RANDOMLY ]
ossprotocol:
oss://oss_endpoint prefix=prefix_name

id=userossid key=userosskey bucket=ossbucket compressiontype=[none|gzip] async=[true|false]

ossprotocol:

oss://oss_endpoint dir=[folder/[folder/]...]/file_name

id=userossid key=userosskey bucket=ossbucket compressiontype=[none|gzip] async=[true|false]

ossprotocol:

oss://oss_endpoint filepath=[folder/[folder/]...]/file_name

id=userossid key=userosskey bucket=ossbucket compressiontype=[none|gzip] async=[true|false]

参考

转自阿里云德哥

转载地址:http://roxea.baihongyu.com/

你可能感兴趣的文章
Linux下的Tftp服务
查看>>
C#将集合和Json格式互相转换的几种方式
查看>>
java连接数据库并操作
查看>>
安装.net framework 4.0时提示HRESULT 0xc8000222
查看>>
集群下文件同步问题
查看>>
ASA 5510 V821 EASY ×××配置
查看>>
ubuntu server 更换源
查看>>
SQL SERVER 2008安装
查看>>
EXT中的gridpanel自适应窗口的方法
查看>>
unary operator expected
查看>>
IPC之共享内存
查看>>
新加坡之旅
查看>>
IBM X3650 M3服务器上RAID配置实战
查看>>
Mysql DBA 高级运维学习之路-索引知识及创建索引的多种方法实战
查看>>
go语言与java nio通信,解析命令调用上下文拉起ffmpeg,并引入livego做的简单流媒体服务器...
查看>>
JavaScript面向对象轻松入门之多态(demo by ES5、ES6、TypeScript)
查看>>
【数据结构】线性表(一):顺序列表
查看>>
利用Mallet工具自动挖掘文本Topic
查看>>
Windows下oracle打补丁步骤
查看>>
Python教程(一)Python简介
查看>>