15.00 - CREATE GLOBAL TEMPORARY TRACE TABLE - Teradata Database

Teradata Database SQL Data Definition Language Detailed Topics

prodname
Teradata Database
vrm_release
15.00
category
Programming Reference
featnum
B035-1184-015K

CREATE GLOBAL TEMPORARY TRACE TABLE

Function of Global Temporary Trace Tables

Like global temporary tables, global temporary trace tables have a persistent definition, but do not retain rows across sessions.

Global temporary trace tables are not hashed. Instead, each table row is assigned a sequential hash sequence. You can perform an INSERT … SELECT operation on the table to copy its rows into a normal hashed table with a primary key, indexes, or additional attributes common to other base table types if you need to do so.

Define the information you want to trace as the input to the UDF. The UDF can then call the FNC_Trace_Write_DL function (see SQL External Routine Programming) that places the information in a global temporary trace table. If the trace is not turned on (see “SET SESSION FUNCTION TRACE” on page 886 and SQL Data Definition Language), the system does no function traceback, though there is still some overhead because the system still calls the UDF.

Make sure to run the trace UDF in non‑protected mode once it has been debugged to ensure that it executes in-line with the procedure. A premature end of the procedure or a rollback of the transaction has no impact on the global temporary trace table, and its contents are not deleted until the session logs off. Enabling function traceback makes your procedure run more slowly because each trace call forces the data to be written into the trace table. Nothing is buffered to ensure that nothing is lost while you are testing a function. See the CREATE GLOBAL TEMPORARY TRACE TABLE “Example 3: Complete Function Traceback Scenario” topic in SQL Data Definition Language for a complete example on how to use a global temporary trace table to do function traceback.

Although global temporary trace tables do not have a primary index, they do not share any other properties with either unpartitioned NoPI tables or column‑partitioned tables.