Teradata中fastload使用

Teradata Fastload Utility 是teradata数据库中一个基于命令行的快速load大量数据到一个空表的工具。

数据可以从以下途径被load:

1) Disk 或 tape;

2) 网络服务器上的文件;

Teradata Fastload使用多个session来load data,但是每一个job只能load到一个表中。如果要load到多个表中,需要提交多个job。

1. fastload脚本文件

SESSIONS 4;  /* optional ,total number of sessions to be allotted for the script */
ERRLIMIT 1000; /* optional */

LOGON localhost/Teradata_Education,Educate; /* tdpid = vivaldi,caracal... */

DROP TABLE stu_fl; /* final target table */
DROP TABLE error_1; /* error table ,internal to fast load utility needed to be defined */
DROP TABLE error_2; /* error table ,internal to fast load utility needed to be defined */

CREATE TABLE stu_fl   /* target table definition */
(
     stu_no       VARCHAR(5),
     stu_name     VARCHAR(10),
     age          VARCHAR(2)
)
PRIMARY INDEX ( stu_no,stu_name,age );

SET RECORD VARTEXT "#";  /* delimiter in the source file */

DEFINE                  /* define the structure of the source file */
     stu_no       (VARCHAR(5)),
     stu_name     (VARCHAR(10)),
     age          (VARCHAR(2))

File=stu_fl.dat;   /* source file location */

SHOW;

BEGIN LOADING stu_fl
ERRORFILES error_1, error_2;

INSERT INTO  stu_fl   /* final insert */
(
stu_no          ,
stu_name     ,
age
)
VALUES
(
:stu_no          ,
:stu_name     ,
:age
)
;

END LOADING;
LOGOFF;

2. fastload数据文件

TDExpress14.0.3_Sles10:~/tough/test # cat stu_fl.dat
10000#Tough00001#26
10001#Tough#26
10002#Tough#26

3. 测试

TDExpress14.0.3_Sles10:~/tough/test # fastload < stu_fl.fastload
     ===================================================================
     =                                                                 =
     =          FASTLOAD UTILITY     VERSION 14.00.00.07               =
     =          PLATFORM LINUX                                         =
     =                                                                 =
     ===================================================================
      ===================================================================
     =                                                                 =
     =          Copyright 1984-2012, Teradata Corporation.             =
     =          ALL RIGHTS RESERVED.                                   =
     =                                                                 =
     ===================================================================
 **** 06:55:47 Processing starting at: Sat Jun 28 06:55:47 2014
 0001 SESSIONS 4;  /* optional ,total number of sessions to be allotted for the s
     cript */
 **** 06:55:47 FDL4866 SESSIONS command accepted
 0002 ERRLIMIT 1000; /* optional */
 **** 06:55:47 Error limit set to: 1000

     ===================================================================
     =                                                                 =
     =          Logon/Connection                                       =
     =                                                                 =
     ===================================================================
 0003 LOGON localhost/Teradata_Education,
 **** 06:55:49 Teradata Database Release: 14.00.03.02
**** 06:55:49 Teradata Database Version: 14.00.03.02
**** 06:55:49 Number of AMPs available: 2
**** 06:55:49 Current CLI or RDBMS allows maximum row size: 64K
**** 06:55:49 Character set for this job: ASCII

0004 DROP TABLE stu_fl; /* final target table */
 **** 06:55:50 Command completed successfully
 0005 DROP TABLE error_1; /* error table ,internal to fast load utility needed to
      be defined */
 **** 06:55:50 RDBMS error 3807: Object ‘error_1‘ does not exist.
 0006 DROP TABLE error_2; /* error table ,internal to fast load utility needed to
      be defined */
 **** 06:55:50 RDBMS error 3807: Object ‘error_2‘ does not exist.

0007 CREATE TABLE stu_fl   /* target table definition */
     (
     stu_no      VARCHAR(5),
     stu_name    VARCHAR(10),
     age         VARCHAR(2)
     )
     PRIMARY INDEX ( stu_no,stu_name,age );
 **** 06:55:50 Command completed successfully

0008 SET RECORD VARTEXT "#";  /* delimiter in the source file */
 **** 06:55:50 Now set to read ‘Variable-Length Text‘ records
**** 06:55:50 Delimiter character(s) is set to ‘#‘
**** 06:55:50 Command completed successfully

0009 DEFINE                  /* define the structure of the source file */
     stu_no      (VARCHAR(5)),
     stu_name    (VARCHAR(10)),
     age         (VARCHAR(2))
     File=stu_fl.dat;   /* source file location */
 **** 06:55:50 FDL4803 DEFINE statement processed

0010 SHOW;
      FILE = stu_fl.dat
     STU_NO                           OFFSET =      0 LEN =     5 VARCHAR
     STU_NAME                         OFFSET =      7 LEN =    10 VARCHAR
     AGE                              OFFSET =     19 LEN =     2 VARCHAR
     TOTAL RECORD LENGTH = 23

0011 BEGIN LOADING stu_fl
     ERRORFILES error_1, error_2;
 **** 06:55:50 Number of FastLoad sessions requested = 4
**** 06:55:50 Number of FastLoad sessions connected = 2
**** 06:55:50 FDL4808 LOGON successful
**** 06:55:50 Number of AMPs available: 2
**** 06:55:50 BEGIN LOADING COMPLETE

     ===================================================================
     =                                                                 =
     =          Insert Phase                                           =
     =                                                                 =
     ===================================================================
 0012 INSERT INTO  stu_fl   /* final insert */
     (
     stu_no      ,
     stu_name    ,
     age
     )
     VALUES
     (
     :stu_no      ,
     :stu_name    ,
     :age
     )
     ;
 **** 06:55:50 Number of recs/msg: 2920
**** 06:55:50 Starting to send to RDBMS with record 1
**** 06:55:50 Sending row 3
**** 06:55:50 Finished sending rows to the RDBMS
 **** 06:55:50 Acquisition Phase statistics:
              Elapsed time: 00:00:00 (in hh:mm:ss)
              CPU time:     0 Seconds
              MB/sec:       N/A
              MB/cpusec:    N/A

     ===================================================================
     =                                                                 =
     =          End Loading Phase                                      =
     =                                                                 =
     ===================================================================
 0013 END LOADING;
 **** 06:55:51 END LOADING COMPLETE
      Total Records Read              =  3
     Total Error Table 1             =  0  ---- Table has been dropped
     Total Error Table 2             =  0  ---- Table has been dropped
     Total Inserts Applied           =  3
     Total Duplicate Rows            =  0
      Start:   Sat Jun 28 06:55:50 2014
     End  :   Sat Jun 28 06:55:51 2014
 **** 06:55:51 Application Phase statistics:
              Elapsed time: 00:00:01 (in hh:mm:ss)
 0014 LOGOFF;
      ===================================================================
     =                                                                 =
     =          Logoff/Disconnect                                      =
     =                                                                 =
     ===================================================================
 **** 06:55:51 Logging off all sessions
**** 06:55:52 Total processor time used = ‘0.36 Seconds‘
     .        Start : Sat Jun 28 06:55:47 2014
     .        End   : Sat Jun 28 06:55:52 2014
     .        Highest return code encountered = ‘0‘.
**** 06:55:52 FDL4818 FastLoad Terminated

4. 查看数据是否load成功

SELECT * FROM TERADATA_EDUCATION. stu_fl ;

数据已经成功load到表中了。

Teradata中fastload使用

时间: 2024-08-04 23:53:41

Teradata中fastload使用的相关文章

Teradata Fastload 使用方法

第一步: 首先打开  teradata fastload.exe 第二步: 通过粘贴导入脚本 脚本: SESSIONS 4; ERRLIMIT 25; SET RECORD VARTEXT ","; LOGON localhost/Teradata_Education,Educate; /* localhost:IP Address; Teradata_Education:user name; Educate:password */ DROP TABLE PT_TEMP_P.RFM_L

SQL-Teradata基础

1.创建一个和表 pnr_1 结构一样的表 Create table pnr_2 as pnr_1 with no data  不含数据 Create table pnr_2 as pnr_1 with  data  含数据 2.NULLIF(exp1,exp2) 当字段exp1与exp2相等时返回 空:当两者不相等时返回 exp1 -------常用在除数不能为0的限制下  RPK/NULLIF(ASK,0) 3.Substr(exp,m,n) 从第m位开始截取,截取长度为 n ------常

PERL获取前后任意月份月末

在BI报表开发时,经常需要计算同比环比,需要用到月末日期,用数据库系统的日期函数操作需要在每处用到日期的地方都把函数写一遍,在某些特殊情形,函数会很复杂,甚至不能实现想要的结果. 比如在Teradata中的Addmonths函数,只计算了月份: 日期 增量值 结果 2015/01/01 1 2015/02/01 2015/01/31 1 2015/02/28 2015/02/28 -1 2015/01/28 2015/03/31 -1 2015/02/28 2015/02/28 0 2015/0

采用ETL with RDBMS模式来实现ETL

目前Teradata数据仓库的ETL作业采用ELT方式, 因为loading太重了, 需要将ETL压力转移到专门的ETL Server上. 对于ETL工具, 市场上已有很成熟的商业/开源工具, 比如Informatica的PowerCenter, IBM的Datastage, 开源的Kettle. 下面是我自己的一些思考, 出发点是, 如何花比较小的代价将ELT模式切换到ETL模式. 我的推荐是: 采用ETL with RDBMS模式, 而不是传统的ETL工具. ETL with RDBMS这个

Teardata SQL Assistant使用技巧

1. 格式化代码 Ctrl+ Q 2. 清除代码 Ctrl+ T 3. 替换代码 Ctrl + H 4. 执行 F5 5. 批量并行执行 F9 6. 字段值为“?”就是null 的意思 7. 创建虚拟临时表 CREATE MULTISET VOLATILE TABLE XXXXXXXXXXXXX ( QQQQ DECIMAL(18,0), WWW DATE FORMAT 'YYYY-MM-DD', DDDD VARCHAR(64) CHARACTER SET LATIN NOT CASESPEC

Teradata数据中包含换行符导致查询结果导出串行问题

Teradata数据中包含换行符导致查询结果导出串行问题 系统在日常运行期间,有部分数据是读取EXCEL导入到生产系统中的.这就导致了数据质量良莠不齐.有的Excel单元格中有换行符,数据导入后,再次查询时,就有可能出现导出结果数据串行的问题. 先来还原这一问题.(还未找到解决方案……T_T) 编写SQL,运行结果如下图: 复制Answer到UE中查看: 利用SQLA自带的导出功能,导出txt查看: 需注意的是,Create table with data 与 insert select运行结果

【Teradata SQL】从中文数字字母混合字符串中只提取数字regexp_substr

目标:从中文数字字母的字符串中只提取数字 sel regexp_substr('mint choc中文11国1','\d+') 原文地址:https://www.cnblogs.com/badboy200800/p/10792095.html

TeraData金融数据模型

Teradata天睿公司(纽交所代码:TDC),是美国前十大上市软件公司之一.经过逾30 年的发展,Teradata天睿公司已经成为全球最大的专注于大数据分析.数据仓库和整合营销管理解决方案的供应商.其提出一种先进的FS-LDM模型(Financial Services Logcial Data Model) --企业级数据模型,包括金融机构业务数据,囊括了银行约80%的业务数据,并把预定义的业务模板连接到核心银行业务数据和数据仓库中. Teradata FS-LDM是一个成熟产品,在一个集成的

fastload错误 — RDBMS error 2634

我们来看一下下面这条语句: BEGIN LOADING stu_flERRORFILES error_1, error_2; 如果此时已经存在error_1或error_2表,那么将会报错,信息如下: 0008 BEGIN LOADING stu_fl ERRORFILES error_1, error_2; **** 07:41:08 Number of FastLoad sessions requested = 4 **** 07:41:08 Number of FastLoad sessi