DELETE
Purpose
Teradata TPump supports the DELETE Teradata SQL statement, which removes rows from a table.
Syntax
where
Syntax Element |
Description |
tname |
Table from which rows are to be deleted tname is qualified either explicitly by database name, or by the current default database. |
WHERE condition |
Conditional clause identifying the row(s) to delete The conditional clause uses values from input data record fields as defined by a FIELD command or TABLE command of the layout referenced by an IMPORT using this statement. |
Usage Notes
The following notes describe how to use DELETE statements following a DML command.
A DELETE statement may also be used in the support environment; normal rules for DELETE are followed in that case.
Teradata TPump operates only on single table statements so DELETE statements must not contain any joins.
To delete records from a table, the username specified on the LOGON command must have DELETE privilege on the specified table.
When the condition(s) of the DELETE statement WHERE clause are evaluated, the result can be definitely true, definitely false, or indeterminate. If the result is true for a specific row, Teradata TPump deletes the row. An indeterminate result, due to an abnormal arithmetic condition such as underflow, overflow, or division by zero, is treated as an error, and Teradata TPump records both row and error code in the error table.
The DELETE statement must identify only one object.
Remember the following when constructing scripts:
The OR construct can be used in the WHERE clause of a DELETE statement; alternatively, two or more separate DML statements (one per OR term) can be used, with the DML statements applied conditionally with the APPLY clause of the IMPORT command. The nature of the alternatives will usually make one of the methods more appropriate.
DML validtime qualifier and NONTEMPORAL semantics are supported. For more information, see SQL Data Manipulation Language (B035‑1146).
Example
The following example uses an input data source containing a series of one‑field, four‑byte records. Each record contains the value (EmpNum) of the primary index column (EmpNo) of a row to be deleted from the Employee table.
.BEGIN LOAD SESSION number;
.LAYOUT Layoutname;
.FIELD EmpNum 1 INTEGER;
.DML LABEL DMLlabelname;
DELETE Employee WHERE EmpNo = :EmpNum;
.IMPORT INFILE Infilename LAYOUT Layoutname APPLY DMLlabelname;
.END LOAD;