Teradata 简明教程
Teradata - FastExport
FastExport 实用程序用于将数据从 Teradata 表导出到平面文件中。它还可以生成报告格式的数据。可以使用 Join 从一个或多个表中提取数据。由于 FastExport 以 64K 块导出数据,因此它对于提取大量数据非常有用。
FastExport utility is used to export data from Teradata tables into flat files. It can also generate the data in report format. Data can be extracted from one or more tables using Join. Since FastExport exports the data in 64K blocks, it is useful for extracting large volume of data.
Example
考虑以下 Employee 表。
Consider the following Employee table.
EmployeeNo |
FirstName |
LastName |
BirthDate |
101 |
Mike |
James |
1/5/1980 |
104 |
Alex |
Stuart |
11/6/1984 |
102 |
Robert |
Williams |
3/5/1983 |
105 |
Robert |
James |
12/1/1984 |
103 |
Peter |
Paul |
4/1/1983 |
以下是 FastExport 脚本的一个示例。它从 employee 表中导出数据,并写入到文件 employeedata.txt 中。
Following is an example of a FastExport script. It exports data from employee table and writes into a file employeedata.txt.
.LOGTABLE tduser.employee_log;
.LOGON 192.168.1.102/dbc,dbc;
DATABASE tduser;
.BEGIN EXPORT SESSIONS 2;
.EXPORT OUTFILE employeedata.txt
MODE RECORD FORMAT TEXT;
SELECT CAST(EmployeeNo AS CHAR(10)),
CAST(FirstName AS CHAR(15)),
CAST(LastName AS CHAR(15)),
CAST(BirthDate AS CHAR(10))
FROM
Employee;
.END EXPORT;
.LOGOFF;
Executing a FastExport Script
一旦脚本编写完成并命名为 employee.fx,你可以使用以下命令执行脚本。
Once the script is written and named as employee.fx, you can use the following command to execute the script.
fexp < employee.fx
执行上述命令之后,将在文件 employeedata.txt 中收到以下输出。
After executing the above command, you will receive the following output in the file employeedata.txt.
103 Peter Paul 1983-04-01
101 Mike James 1980-01-05
102 Robert Williams 1983-03-05
105 Robert James 1984-12-01
104 Alex Stuart 1984-11-06
FastExport Terms
以下是 FastExport 脚本中常用的术语列表。
Following is the list of terms commonly used in FastExport script.
-
LOGTABLE − Specifies the log table for restart purpose.
-
LOGON − Logs into Teradata and initiates one or more sessions.
-
DATABASE − Sets the default database.
-
BEGIN EXPORT − Indicates the beginning of the export.
-
EXPORT − Specifies the target file and the export format.
-
SELECT − Specifies the select query to export data.
-
END EXPORT − Specifies the end of FastExport.
-
LOGOFF − Ends all sessions and terminates FastExport.