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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. [Hive - LanguageManual] Import/Export

    LanguageManual ImportExport     Skip to end of metadata   Added by Carl Steinbach, last edited by Le ...

  4. 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 ...

  5. sqoop import/export使用经验

    一.先创建一个小表(test_01)进行测试(主节点IP:169.254.109.130/oracle服务器IP:169.254.109.100) 1.测试连接oracle; sqoop list-t ...

  6. SQL Azure (18) 使用External Table实现垮库查询

    <Windows Azure Platform 系列文章目录> 问题 1.我们在进行SQL Server开发的时候,经常会使用垮库查询.但是在默认情况下,使用Azure SQL Datab ...

  7. 前端 高级 (二十五)vue2.0项目实战一 配置简要说明、代码简要说明、Import/Export、轮播和列表例子

    一.启动服务自动打开浏览器运行 二.配置简要说明 1.node_modules 安装好的依赖文件,中间件等,所在位置 2.package.jason 配置当前项目要安装的中间件和依赖文件 { &quo ...

  8. es6 import export 引入导出变量方式

    var testdata='sdfkshdf'; //export testdata;//err export {testdata as ms}; export var firstName = 'Mi ...

  9. 探讨ES6的import export default 和CommonJS的require module.exports

    今天来扒一扒在node和ES6中的module,主要是为了区分node和ES6中的不同意义,避免概念上的混淆,同时也分享一下,自己在这个坑里获得的心得. 在ES6之前 模块的概念是在ES6发布之前就出 ...

随机推荐

  1. Linux中exit与_exit的区别

    在exit,_exit的区别 - exit()与_exit()函数的区别(Linux系统中)2012-03-20 15:19:53 分类: LINUX 注:exit()就是退出,传入的参数是程序退出时 ...

  2. IOS 中openGL使用教程3(openGL ES 入门篇 | 纹理贴图(texture)使用)

    在这篇文章中,我们将学习如何在openGL中使用纹理贴图. penGL中纹理可以分为1D,2D和3D纹理,我们在绑定纹理对象的时候需要指定纹理的种类.由于本文将以一张图片为例,因此我们为我们的纹理对象 ...

  3. Window对象方法

    Window对象方法 scrollBy() 按照指定的像素值来滚动内容. scrollTo() 把内容滚动到指定的坐标. setInterval() 按照指定的周期(以毫秒计)来调用函数或计算表达式. ...

  4. public static void Invoke (Action action)

    using System; using System.Security.Principal; using System.Security.Permissions; namespace Demo { c ...

  5. android bundle存放数据详解

    转载自:android bundle存放数据详解 正如大家所知道,Activity之间传递数据,是将数据存放在Intent或者Bundle中 例如: 将数据存放倒Intent中传递: 将数据放到Bun ...

  6. 11,SFDC 管理员篇 - 报表和数据的可视化

    1,Report Builder 1,每一个report type 都有一个 primay object 和多个相关的object 2,Primary object with related obje ...

  7. ios 使用Core Image实现高斯模糊

    在iOS和OS X平台上,Core Image都提供了大量的滤镜(Filter),这也是Core Image库中比较核心的东西之一.按照官方文档记载,在OS X上有120多种Filter,而在iOS上 ...

  8. 英语学习app分析

    以下数据分析由队员张波收集整理队员链接 队友的博客 一.数据统计 为了让统计数据更加准确可信,我们选取了三款android平台的应用市场软件作为数据的来源. 英语学习app下载量统计表: 序号 应用名 ...

  9. git笔记 常规使用

    1. 创建分支    git checkout -b fetch_name 2. 添加快照进行登记 git add . 3.登记到仓库 git commit -m 'message' git comm ...

  10. AngularJS-chapter1-2-四大特性

    4大特性 MVC MVC实例  数据模型,控制器,视图 HelloAngular_MVC.html 图中的 ng-controller="HelloAngular"  定义了Hel ...