Netezza External Tables --How to use local files in external table
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的更多相关文章
- 管理外部表(External Tables)
Oracle数据库允许对外部表中的数据进行只读访问.外部表定义为不驻留在数据库中的表,并且可以是为其提供访问驱动程序的任何格式.通过为数据库提供描述外部表的元数据,数据库能够公开外部表中的数据,就好像 ...
- Github Clone to local files
cd to you local files address key the word: git clone -0 github https://github.com/xxxxxxxxx Done... ...
- 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 ...
- 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'@' ...
- how to force git to overwritten local files
最佳解决方法 重要提示:如果您有任何本地更改,将会丢失.无论是否有--hard选项,任何未被推送的本地提交都将丢失. 如果您有任何未被Git跟踪的文件(例如上传的用户内容),这些文件将不会受到影响. ...
- 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 ...
- Hive Tutorial 阅读记录
Hive Tutorial 目录 Hive Tutorial 1.Concepts 1.1.What Is Hive 1.2.What Hive Is NOT 1.3.Getting Started ...
- Programming Impala Applications
Programming Impala Applications The core development language with Impala is SQL. You can also use J ...
- ocp 1Z0-047 131-276题解析
131. Which view would you use to display the column names and DEFAULT valuesfor a table?A. DBA_TABLE ...
随机推荐
- ANE-IOS与AS的互通
从AS调用IOS的函数与传参数 extContex是ExtensionContext的实例,通过call调用.第一个参数是IOS对应的函数,之后所有的参数会变成一个数组传入IOS中.也就是说函数名称后 ...
- 2. Python的划分
解释型:当程序运行时,将代码从上至下,一句一句解释成二进制,在执行. 典型:python,php 优点:开发速度快,可以跨平台. 缺点:执行效率慢 编译型:将源码一次性转化成二进制文件,然后在执行. ...
- CYJian的水题大赛2 解题报告
这场比赛是前几天洛谷上 暮雪﹃紛紛dalao的个人公开赛,当时基本上都在水暴力分......也没有好好写正解(可能除了T1) 过了几天颓废的日子之后,本蒟蒻觉得应该卓越一下了qwq,所以就打算写一个解 ...
- Rabbitmq消息服务器通讯异常: name must not be blank
前人挖坑,后人填! 倒霉的遇到一个破项目,该 项目使用了 RabbitMQ 消息队列向服务器发送消息, 但在发送中老是报 RabbitMQ 服务器异常! 呃,查看了服务器,服务器好好的,日志中却是这样 ...
- Linux下的find查找命令
Linux下的查找命令有:which(查看可执行文件的位置),whereis(查看指定文件的位置),locate(配合数据库查找指定文件的内容).find(在磁盘上查找文件).grep(使用正则表达式 ...
- git恢复到上次提交
4个区 5种状态 未修改(Origin) 已修改(Modified) 已暂存(Staged) 已提交(Committed) 已推送(Pushed) 检查修改 已修改,未暂存(检查工作区与暂存区间的差异 ...
- SQL SERVER中的二种获得自增长ID的方法
新方法 insert into TblClass output inserted.tClassId values('Hi~班','英语班') 老方法 insert into 表名 () values ...
- JavaWeb学习笔记(十五)—— 使用JDBC进行批处理
一.什么是批处理 批处理就是一批一批的处理,而不是一个一个的处理! 当你有10条SQL语句要执行时,一次向服务器发送一条SQL语句,这么做效率上很差!处理的方案是使用批处理,即一次向服务器发送多条SQ ...
- 2019 CCPC-Wannafly Winter Camp Day7(Div2, onsite)
solve 6/11 补题: A.迷宫 Code:zz Thinking:zz kk 把每个节点的深度都处理出来,同一深度的点的冲突度为 (x-1),x为同层次点数减一. 然后冲突度不断下传(冲突度为 ...
- 矩阵快速幂--51nod-1242斐波那契数列的第N项
斐波那契额数列的第N项 斐波那契数列的定义如下: F(0) = 0 F(1) = 1 F(n) = F(n - 1) + F(n - 2) (n >= 2) (1, 1, 2, 3, 5, 8, ...