Working with Event Tables

You can perform a subset of table operations on an event table, which is specifically designed for capturing events. The sections in this topic describe the operations an event table supports.

Operations Supported on an Event Table

Because an event table is designed specifically for capturing events, you cannot perform some of the operations on an event table that you can perform on a table.

With an event table, you can perform only the following operations:

Deleting Rows from an Event Table

If you need to delete rows from an event table, you can use the following commands:

  • Use TRUNCATE TABLE to remove all rows from the event table.

  • Use DELETE to remove selected rows from the event table.

    You can use this if you need to implement more complex log retention policies (e.g. if you need to retain logs for some functions for a longer period of time than other functions).

Parameters for Event Tables

You can use the following parameters to specify how the event table should be used by handler code.

EVENT_TABLE

Specifies the name of the event table for logging messages from stored procedures and UDFs in this account. For reference information, refer to EVENT_TABLE.

LOG_LEVEL

Specifies the severity level of messages that should be ingested and made available in the active event table. Messages at the specified level (and at more severe levels) are ingested. For more information, refer to LOG_LEVEL and Setting log level.

TRACE_LEVEL

Specifies the verbosity of trace events that should be ingested and made available in the active event table. Events at the specified level are ingested. For more information, refer to TRACE_LEVEL and Setting trace level.

Access Control Privileges for Event Tables

You can use privileges in the global and event table scope to manage access to operations on an event table.

For more information, refer to Event table privileges and log level privileges in Global privileges (account-level privileges).

Managing Access to Event Table Data

When it’s impractical for you to make event table data available to a range of users and roles, you can create views for access by users with specific roles.

An account can have only one active event table. When you want to manage access to the data in this single table, you can create views on the event table, then grant access for each view to separate roles. Through the view, a role might have access to specified subset of the data in the event table.

For more information about creating view, refer to CREATE VIEW.

Using Streams to Track Changes to Event Tables

You can create a stream on an event table, such as to capture changes to the table.

For more information about streams, refer to Change Tracking Using Table Streams and CREATE STREAM.

Code in the following example creates a stream to capture inserts on the event table my_event_table.

CREATE STREAM append_only_comparison ON EVENT TABLE my_event_table APPEND_ONLY=TRUE;
Copy