DB2 table access list - db2

i want to find db2 tables access list(which user or program has privilige which table). how can i query this?
If i would write this psedue code i wil be like this.
select table's_grant_user_name from sysibm.... where table_name='XXX'`
is there any ibm privillige table been in db2?
In aqt tool i can see tables access list when i select from combobox. But i need this query to querying for some tables to groupping.
is it possible to query this ? how can i retrieve table's grant list?
Thanks,

Check out the view SYSIBMADM.PRIVILEGES.

Related

Postgresql: how to get all queries to a tables or database for a current user?

I need to get all queries to a tables for current user in Postgresql, how to do that? I need it for an audit. I installed pgbadger but it was not show queries its just showing a count of some queries,for example, user1 have made 3 queries to a table1, but i need to get something like this: “user1 made select * from table1 at %timestamp%; user1 made alter table … “ and etc. could someone help?
i used pgbadger and try this solution from postgres off docs
in-build tool for monitor user activity

How to get all external in db2 using a system tables information

I need to get complete list of external tables in db2 database. I have defined schema called DB2INST1. How to get complete list of external tables information using system tables?
The information lives in syscat.tables (documentation here) for Db2-LUW databases that support external tables, which have their PROPERTY column with value Y in position 27 of that column.
Example query returns the fully qualified name of external tables:
select trim(tabschema)||'.'||rtrim(tabname)
from syscat.tables
where substr(property,27,1)='Y'
with ur;
In general, the best and most reliable way to retrieve all information and to recreate the DDL statements for tables is to use the db2look tool. If you want to extract the metadata on your own, there are some catalog views to start with:
SYSCAT.TABLES holds the table information. Look for the PROPERTY column and check there if it is an external table.
SYSCAT.COLUMNS has the basic column information. But there are more related tables depending on types and attributes.
SYSCAT.EXTERNALTABLEOPTIONS shows the actual options for an external table, the things in addition to what makes a regular table.
There are many more tables to hold table properties, depending on the complexity of the table and column definitions.

What is pg_class in Postgres and how to see it using pgAdmin 4?

I'm new to Postgresql and I just saw my friends query on a cakePhp controller that call 'pq_class'. I tried to look up to my PostgreSQL database and find out what's inside using pgAgmin4.
Unfortunately, I can't see any table name with 'pg_class'. I tried to google and find these pages :
https://www.postgresql.org/docs/current/catalog-pg-class.html
postgreSQL - pg_class question
But I am still confused about pg_class. Is there any good or real explanation about pg_class and how to see it using pgAdmin4 without using any query (just right click -> view data)
pg_class is an internal system table that stores information about tables (and similar objects") available in the database. Every database product has such a collection of system tables (and views) that it maintains.
You can (and in most cases should) use the views from the information_schema if you want to see information about tables, columns, views and other database objects.
You can get details from information_schema on pgadmin like this.
`
SELECT * FROM information_schema.columns;
select * from information_schema.tables`

postgres db trigger to log query type into another table

This problem scenario may sounds strange but I am trying to write a trigger to log the query type into another table and so far i havent been able to find anything on google
the database i am using is postgres
i.e.
if i have two tables; table1 and querylog(has a string field called querytype)
and a select query is executed on table1, i want to insert a row into the query log table with the querytype field populated with "select"
anyone have any idea how to reference the query type in a function that will be called by a trigger?
Triggers do not get called for SELECT queries, so that won't work.
If you want to audit queries, you can use the PostgreSQL log file or tools like pgaudit that hook into PostgreSQL to retrieve and log the information.

PostgreSQL: How to delete dynamically created table using SQL

I am developing a windows application and using Postgres as backend database. At some point in my application i am dynamically creating table e.g Table1, then Table2 and so on. In this way i have many dynamic table in my database. Now i provide a button "Clean Database", so i need to remove all those dynamic tables using SQL query. Should some one guide me how to write SQL Query that automatically delete all such tables?
You should just be able to say
DROP TABLE {tablename}
for each dynamically created table. Try that and see if it works.