Teradata Database provides queue tables that you can use for event processing. Queue tables are base tables with first-in-first-out (FIFO) queue properties.
When you create a queue table, you define a timestamp column. You can query the queue table to retrieve data from the row with the oldest timestamp.
An application can perform peek, FIFO push, and FIFO pop operations on queue tables.
|To perform a …||Use the …|
|FIFO push||INSERT statement.|
|FIFO pop||SELECT AND CONSUME statement.|
Here is an example of how an application can process events using queue tables:
- Define a trigger on a base table to insert a row into the queue table when the trigger fires.
- From the application, submit a SELECT AND CONSUME statement that waits for data in the queue table.
- When data arrives in the queue table, the waiting SELECT AND CONSUME statement returns a result to the application, which processes the event. Additionally, the row is deleted from the queue table.
For more information about:
- Creating queue tables, see the CREATE/REPLACE TABLE statement in SQL Data Definition Language - Syntax and Examples, B035-1144.
- SELECT AND CONSUME, see SQL Data Manipulation Language , B035-1146 .