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.
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 |
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;
Once the script is written and named as employee.fx, you can use the following command to execute the script.
fexp < employee.fx
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
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.