Query Logging User Rules | BEGIN QUERY LOGGING | Teradata Vantage - 17.10 - Query Logging User Rules - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Detailed Topics

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1184-171K
Language
English (United States)

Because you can log different information for different users, the system table DBC.DBQLRuleTbl maintains the various logging rules for each user. These rules are based on the logon account string for each logged user and are maintained in cache to promote their quick access.

This topic does not describe the rules hierarchy, but can be helpful for understanding default accounts and DBQL rules. See Hierarchy of Applying Database Query Logging Rules.

You must access the DBC.DBQLRulesV view. You cannot access either DBC.DBQLRuleTbl or DBC.DBQLRuleCountTbl directly.

Sessions are always associated with an account. At logon, the session is associated with the default account of the user who is logging on unless the logon string for that user specifies a different account assignment. See the logon pointer information in Teradata® Call-Level Interface Version 2 Reference for Workstation-Attached Systems, B035-2418.

DBQL searches for rules in the following order:
  1. Local cache.
  2. Rules database.

Assume that user1 has a default account of abc, but is also assigned to account def and that you have submitted the following BEGIN QUERY LOGGING requests:

BEGIN QUERY LOGGING ON ALL ACCOUNT = 'ABC';

BEGIN QUERY LOGGING WITH OBJECTS ON user1 ACCOUNT = 'def';

In this scenario, if a user does not specify an account string when logging on, then the system applies the ALL rule instead of the user1 rule.

IF user1 logs on … THEN the following rule applies …
specifying account def user1.

The system uses the rule specified by the following request to log the user1 queries and to log objects for those queries.

     BEGIN QUERY LOGGING WITH OBJECTS
       ON user1
       ACCOUNT =  'def ';
without specifying an account ALL.

The system uses the rule specified by the following request to log the user1 queries, but does not log object information about them.

BEGIN QUERY LOGGING
  ON ALL
  ACCOUNT =  'abc ';