FROM: http://tennysusantobi.blogspot.com/2012/08/netezza-external-tables.html

Netezza External Tables

 

You can use Netezza's external table to view data from an external file
and use it like a database table. When you create an external table, the
actual data still sits in that physical external file, but you can
query it from Netezza like you can query a normal database table.

You can also use external tables to export data out of a Netezza table into a file.

From Netezza's Data Loading Manual  - An external table allows Netezza
to treat an external file as a database table. An external table has a
definition (a table schema), but the actual data exists outside of the
Netezza appliance database. External tables can be used to access files
which are stored on the Netezza host server or, in the case of a remote
external table, Netezza can treat a file on a client system as an
external table (see REMOTESOURCE option).

Below are 2 examples to show you how to do both data export and "import".

I am using Aginity Workbench for Netezza on my windows machine (which
comes with a netezza odbc driver), and I have a text file stored in my
local drive C:\temp\testfile.txt which has the following column header
and 3 rows:

employeeid,employeename,salary
1,'John Lee',100000
2,'Marty Short', 120000
3,'Jane Mars', 150000

CREATE EXTERNAL TABLE ext_tbl_employees(
employee_id integer, 
employee_name character varying(100), 
salary decimal (10,2))
USING (
dataobject('c:\temp\testfile.txt') 
remotesource 'odbc'
delimiter ','
skiprows 1);

Then in your Aginity workbench object browser, expand the folder
External Tables, and you will your new external table listed there.

You can then query the table just like a normal database table:

select *
from ext_tbl_employees

You can also create a transient external table, in which it only exists
for the duration of your query, which means the external table
definition does not persist in the system catalog.

--transient external table
SELECT 
employee_id,
employee_name,
salary
FROM EXTERNAL 'c:\temp\testfile.txt' 
(
employee_id integer, 
employee_name character varying(100), 
salary decimal (10,2))
USING (
remotesource 'odbc'
delimiter ','
skiprows 1);

Transient external table is also a very useful way to export data from a
netezza database out to a text file. You can export not just an entire
table, but the output of any sql statement. The beauty of it is you
don't have to specify the schema definition of the data, which can save
you a lot of typing:

create table mytesttable (
studentid integer,
studentname character varying(100)
);

insert into mytesttable 
select 1, 'Jane Doe'
union
select 2, 'John Smith';

CREATE EXTERNAL TABLE 'c:\Temp\ExportDataTest.csv' USING (remotesource 'ODBC' DELIM ',') AS
SELECT *
from mytesttable;

drop table mytesttable;

Note: if the file already exists, any existing data will be deleted by Netezza before it inserts data.

If there's comma in your data, and you want to export to csv, use escapeChar option:

CREATE EXTERNAL TABLE 'c:\Temp\OfferAttributesNightlyFeed.csv' USING (remotesource 'ODBC' DELIM ',' ESCAPECHAR '\') AS
SELECT *
from COUPONATTRIBUTESTEST;

Netezza External Tables --How to use local files in external table的更多相关文章

  1. 管理外部表(External Tables)

    Oracle数据库允许对外部表中的数据进行只读访问.外部表定义为不驻留在数据库中的表,并且可以是为其提供访问驱动程序的任何格式.通过为数据库提供描述外部表的元数据,数据库能够公开外部表中的数据,就好像 ...

  2. Github Clone to local files

    cd to you local files address key the word: git clone -0 github https://github.com/xxxxxxxxx Done... ...

  3. Force git to overwrite local files on pull 使用pull强制覆盖本地文件 转载自:http://snowdream.blog.51cto.com/3027865/1102441

    How do I force an overwrite of local files on a git pull? I think this is the right way: $ git fetch ...

  4. mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts' when using LOCK TABLES

    AutoMySQLBackup备份时,出现mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'root'@' ...

  5. how to force git to overwritten local files

    最佳解决方法 重要提示:如果您有任何本地更改,将会丢失.无论是否有--hard选项,任何未被推送的本地提交都将丢失. 如果您有任何未被Git跟踪的文件(例如上传的用户内容),这些文件将不会受到影响. ...

  6. Track files and folders manipulation in Windows

    The scenario is about Business Secret and our client do worry about data leakage. They want to know ...

  7. Hive Tutorial 阅读记录

    Hive Tutorial 目录 Hive Tutorial 1.Concepts 1.1.What Is Hive 1.2.What Hive Is NOT 1.3.Getting Started ...

  8. Programming Impala Applications

    Programming Impala Applications The core development language with Impala is SQL. You can also use J ...

  9. ocp 1Z0-047 131-276题解析

    131. Which view would you use to display the column names and DEFAULT valuesfor a table?A. DBA_TABLE ...

随机推荐

  1. S.O.L.I.D原则

    SILID原则: 是面向对象编程和设计的重要原则,在我们编程的过程中是谨记的重点,所以对其有深刻了解是必须的.   < Clean Code(代码整洁之道)>作者Robert C. Mar ...

  2. 比特币解锁脚本中的ScriptSignature都包含了什么东西

    比特币 解锁脚本signature script 包含了那些东西? 使用 UTXO 需要私钥签名,私钥到底都签了什么东西呢?一直比较好奇. 比特币的私钥签名总共有五中类型,具体见 btcd 代码,如下 ...

  3. 性能测试工具Locust的介绍和使用

    内容来自网络 https://www.w3xue.com/exp/article/20191/16707.html https://blog.csdn.net/qq_36255988/article/ ...

  4. 非固定参数:*args和 **kwargs

    先看一个固定参数栗子: def func1(x, args): print(x, args) func1(1,22) ====================1 22 ================ ...

  5. PHP内核研究 静态变量

    静态变量 它可以是 静态全局变量,如果不调用unset,那么这个静态变量会一直存在,直到程序退出时才由Zend内存管理来释放 它可以是 静态局部变量:在函数里定义,函数执行完后,该静态变量不会消失 它 ...

  6. 2,ThreadGroup 概念以及用法

    当一个任务需要多个子线程去处理业务,这时候不希望这些子线程杂乱无章, 就需要把这些线程统一管理起来,这时候线程组就产生了. ThreadGroup  常用方法讲解 activeCount()   返回 ...

  7. css中的block与none

    *{ display:none; } div{ display:block; } div 会正常显示粗来吗?不会 因为*代表所有元素,包括div的父级元素html,body 父级元素都不显示了,子元素 ...

  8. Selenium三种等待元素的方式及代码,需要特别注意implicitlyWait的用法

    一.显式等待 1.显式等待: 就是明确的要等到某个元素的出现或者是某个元素的可点击等条件,等不到,就一直等,除非在规定的时间之内都没找到,那么就跳出Exception. 2.代码: new WebDr ...

  9. JavaWeb学习笔记(二十一)—— 监听器Listener

    一.监听器概述 JavaWeb中的监听器是Servlet规范中定义的一种特殊类,它用于监听web应用程序中的ServletContext, HttpSession和 ServletRequest等域对 ...

  10. L2-2 小字辈 (25 分)

    本题给定一个庞大家族的家谱,要请你给出最小一辈的名单. 输入格式: 输入在第一行给出家族人口总数 N(不超过 100 000 的正整数) —— 简单起见,我们把家族成员从 1 到 N 编号.随后第二行 ...