17.05 - Example: Logging Requests Except for a Single User and Account - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1144-175K
Language
English (United States)

To log all users for SQL, but not log any requests from the myuser2 account 'marketing ' pair. If myuser2 submits a request under account 'marketing', DBQL does not log the request. However, if myuser2 logs on with account 'sales', DBQL logs the request and the system captures the SQL text for myuser2:'sales ' in DBC.DBQLSQLTbl.

To replace an existing rule for myuser2, you can either submit a REPLACE QUERY LOGGING request or submit an END QUERY LOGGING request followed by a new BEGIN QUERY LOGGING request. See REPLACE QUERY LOGGING and END QUERY LOGGING.

These two requests enable query logging with SQL for all users, but exclude requests for the myuser2:'marketing’ pair:

     BEGIN QUERY LOGGING WITH SQL ON ALL; 
     BEGIN QUERY LOGGING WITH NONE ON myuser2 ACCOUNT='marketing';

These two requests remove the rules for logging all users for SQL with the exclusion of the myuser2:'marketing’ pair:

     END QUERY LOGGING ON ALL;
     END QUERY LOGGING ON myuser2 ACCOUNT='marketing';

To replace existing rules with a new rule set, submit a REPLACE QUERY LOGGING request. See REPLACE QUERY LOGGING.