Saturday 7 March 2015

Find the query run by each user in Teradata - username to userid mapping in dbqlogtbl

First step is to enable query logging on Teradata for the User.

We need to enable query logging from DBC user. If you try to enable query logging using any other user, you will get an error that the user does not have 'Statement' permission.

Error code:

Failure 3523 (username does not have statement permission)

Example script:

---- enable query logging so that all the queries run by a particular user is logged
begin query logging with sql on training_1 ;

The below query will now give all the queries run by user 'Training_1'


select * from dbc.users;
select * from dbc.dbase;
select db1.databasename,dblog1.*from dbc.dbqlogtbl as dblog1
inner join
dbc.dbase as db1
on dblog1.userid = db1.databaseid
where db1.databasename = 'training_1';

We can end query logging using:

End query logging on user = 'training_1';

Please give us your valuable feedback and like us on Google Plus or LinkedIn.


No comments:

Post a Comment

Please share your thoughts and let us know the topics you want covered