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发布之前就出 ...
随机推荐
- 【HOW】如何限制Reporting Services报表导出功能中格式选项
Reporting Services报表导出功能中缺省会提供多种导出格式选项,但很多情况下不需要全部的格式选项,因此需要对这些选项进行限制.下面我们以SQL Server 2008 R2为例来说明对这 ...
- C# 多线程线程池( 一 )
我们将在这里进一步讨论一些.NET类,以及他们在多线程编程中扮演的角色和怎么编程.它们是: System.Threading.ThreadPool 类 System.Threading.Timer 类 ...
- XMLHttpRequest简单总结
一.概念 XMLHttpRequest 对象用于在后台与服务器交换数据. XMLHttpRequest 对象是能够: 在不重新加载页面的情况下更新网页 在页面已加载后从服务器请求数据 在页面已加载后从 ...
- nodejs——qureystring的作用
当node服务器向另一个服务器发送数据时,首先要转换成字符串再post或者get,这个时候就要用到node内置的这个包querystring, querystring.stringify(data);
- 利用Flex组件birdeye绘制拓扑关系图
birdeye绘制拓扑关系图 1.flex简单介绍 Flex 是一个高效.免费的开源框架,可用于构建具有表现力的 Web应用程序,这些应用程序利用Adobe Flash Player和Adobe AI ...
- python:让源码更安全之将py编译成so
应用场景 Python是一种面向对象的解释型计算机程序设计语言,具有丰富和强大的库,使用其开发产品快速高效. python的解释特性是将py编译为独有的二进制编码pyc文件,然后对pyc中的指令进行解 ...
- js 中文乱码解决方法
bookManageAdd: function () { top.MainFrameJS.confirm = true; var action = getQueryS ...
- 利用nodejs的cheerio抓取网站数据
/*引入模块*/ var http = require('http') var url = 'http://www.cnblogs.com/txxt' var cheerio = require('c ...
- java守护线程的理解
package daemonThread; /*setDaemon(true)方法将线程设置为守护线程,线程的Daemon默认值为false * 只要当前JVM实例中存在任何一个非守护线程没有结束,守 ...
- [C]遍历目录下所有文件
#include<iostream>#include<string.h>#include<io.h>FILE *fp;using namespace std;voi ...