Data import/export of Netezza using external table
Introduction
External table is a special table in Netezza system, which could be used to import/export data between flat files and Netezza directly.
Import data from external file to Netezza
Grammar:
CREATE EXTERNAL TABLE EXTERNAL_TABLE_TEST
(
id int,
name varchar(50)
)
USING
(
DATAOBJECT('/mnt/external_files/Test.txt')
--other settings
);
In this scenario, external table is kind of like a pointer. It could be used by other SQL statements, like: CREATE <TABLE_NAME> AS SELECT * FROM EXTERNAL_TABLE_TEST.
Since it is not the real table, once the external table is created, it is not allowed to alter the data of the external table.
For the external file location, it should be an address of the Netezza host linux box.? ODBC driver?
When the requirement is only to check the data in the external file, there is no need to store a external table, then a transient external table(TET) could be used.
Here is an example of TET table:
SELECT * FROM EXTERNAL '/mnt/external_files/Test.txt'
(
id int,
name varchar(50)
)
USING
(
--settings
);
Basically, when using EXTERNAL '...' (...) USING (...), the system will create a TET table when executing the query. The TET phrases could also be used as a part of other SQL statements, like:
INSERT INTO <TABLE_NAME> SELECT * FROM EXTERNAL '...' (...) USING (...)
CREATE <TABLE_NAME> AS SELECT * FROM EXTERNAL '...' (...) USING (...)
Export data from Netezza to external file
Grammar:
CREATE EXTERNAL TABLE [EXTERNAL_TABLE_TEST] '/mnt/external_files/nzoutput.txt'
USING
(
DELIM ','
--other settings
)
AS
SELECT * FROM OUTPUT_TABLE
;
The grammar is similar, and external table is also like a pointer to the file. Each time the query executed, the external file will be refreshed. If the EXTERNAL_TABLE_TEST name is , then a system TET will be used.
So it is not allowed to alter the external table?
The external table could also be used by other SQL statements?
external file could be modified?
File format setting
Basically, there are two kinds of format for a file, delimited(default) and fixed. Here is an example of external file with FIXED FORMAT.
DROP TABLE Test_Fixed;
CREATE EXTERNAL TABLE Test_Fixed
(
ID BIGINT,
NAME VARCHAR(10),
)
USING
(
DATAOBJECT('/mnt/test.txt')
FORMAT 'FIXED'
LOGDIR '/tmp/test.txt'
LAYOUT
(
BYTES 19,
BYTES 10
)
);
SELECT * FROM Test_Fixed;
There are many other settings, here is the most frequently ones:
ENCODING 'UTF8'-- default is INTERNAL, which is for ansi file
SKIPROWS 1 -- Skip the first row, this is usually setted when the file has a header row.
FORMAT 'FIXED' --default is text, which means the delimited format
DELIMITER ',' --default is pipe, this is limited to only one character
ESCAPECHAR '/' --this is used when the file is delimited and the delimiter is included as the data
QUOTEDVALUE double --default is no quotedvalue
LOGDIR '/mnt/hqaasan01/development_adhoc/' --specify the log dir, the log is very helpful when troubleshooting
Note: Since Netezza host is a Linux box, the import/export file format could only be linux format(use LF as row delimiter).
External articles
http://www.cnblogs.com/s021368/p/3582914.html
Data import/export of Netezza using external table的更多相关文章
- Netezza External Tables --How to use local files in external table
FROM: http://tennysusantobi.blogspot.com/2012/08/netezza-external-tables.html Netezza External Table ...
- 1.3 Quick Start中 Step 7: Use Kafka Connect to import/export data官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 7: Use Kafka Connect to import/export ...
- [Hive - LanguageManual] Import/Export
LanguageManual ImportExport Skip to end of metadata Added by Carl Steinbach, last edited by Le ...
- Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler--转载
原文地址:https://gist.github.com/maxivak/3e3ee1fca32f3949f052 Install Solr download and install Solr fro ...
- sqoop import/export使用经验
一.先创建一个小表(test_01)进行测试(主节点IP:169.254.109.130/oracle服务器IP:169.254.109.100) 1.测试连接oracle; sqoop list-t ...
- SQL Azure (18) 使用External Table实现垮库查询
<Windows Azure Platform 系列文章目录> 问题 1.我们在进行SQL Server开发的时候,经常会使用垮库查询.但是在默认情况下,使用Azure SQL Datab ...
- 前端 高级 (二十五)vue2.0项目实战一 配置简要说明、代码简要说明、Import/Export、轮播和列表例子
一.启动服务自动打开浏览器运行 二.配置简要说明 1.node_modules 安装好的依赖文件,中间件等,所在位置 2.package.jason 配置当前项目要安装的中间件和依赖文件 { &quo ...
- es6 import export 引入导出变量方式
var testdata='sdfkshdf'; //export testdata;//err export {testdata as ms}; export var firstName = 'Mi ...
- 探讨ES6的import export default 和CommonJS的require module.exports
今天来扒一扒在node和ES6中的module,主要是为了区分node和ES6中的不同意义,避免概念上的混淆,同时也分享一下,自己在这个坑里获得的心得. 在ES6之前 模块的概念是在ES6发布之前就出 ...
随机推荐
- R&S学习笔记(二)
1.OSPF:路由条目1万多条.收敛时间1s:ISIS:路由条目可以达2万多条,收敛时间50ms().ISIS在链路层上面,不依赖IP这层,这样给了它很多可能.比如IPv4, IPv6路由的混合承载, ...
- Druid 基础使用-操作篇(Pivot、plyql)
一.Pivot --9095 端口 二.基本sql 使用 .plysql-- http://plywood.imply.io/plyql (下面的端口应该是8082,我这个地方做了端口转换) ...
- Ubuntu12.04解决gedit中文乱码问题
Ubuntu12.04,终端中分别输入下面两条指令: gsettings set org.gnome.gedit.preferences.encodings auto-detected “['GB18 ...
- ubuntu 13.10 mono asp.net服务 安装
ubuntu 13.10 从官方文档http://www.mono-project.com/Mod_mono 可看到 Mod_Mono is an Apache 2.0/2.2/2.4.3 modul ...
- C#的互操作性:缓冲区、结构、指针
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Linux学习四:UDP编程(上)
关于UDP和TCP对比优缺,这里就不说了. 使用UDP代码所掉用的函数和用于TCP的函数非常类似,这主要因为套接口库在底层的TCP和UDP的函数上加了一层抽象,通过这层抽象使得编程更容易,但失去了一些 ...
- 在SQL SERVER中根据某字段分隔符将记录分成多条记录
XT_RSGL_KQSZ_LS表结构如下图: CREATE TABLE XT_RSGL_KQSZ_LS( KQFW VARCHAR(400) ) 其中KQFW字段以分割符 , 隔开 INSERT I ...
- python模块之configparser
configparser用于处理特定格式的文件,其本质上是利用open来操作文件. # 注释1 ; 注释2 [section1] # 节点 k1 = v1 # 值 k2:v2 # 值 [section ...
- css3 text-overflow属性
页面: <ul> <li>· 测试测试测试测试测试测试</li> <li>· 测试测试测试测试测试测试</li> <li>· 测 ...
- HttpResponseMessage和HttpResponseException (转)
Web API 中提供了 HttpResponseMessage 与 HttpResponseException 用于处理返回讯息,HttpResponseMessage 用于返回一个来自于客户端的请 ...