Get all tables from all databases by a query - db2

I want to get a list of all the tables in all the DBs like: db_name, table_name, card
I tried sysibm.tables, syscat.tables & sysibm.systables but they all relevant to the current DB I'm connecting to..
what basically I'm looking for is equivalent to DBA_TABLES / CDB_TABLES in oracle..

Related

postgres query for different tables

I am new to postgres. I am trying to make the following query dynamic for different tables.
SELECT DISTINCT jsonb_object_keys(elements -> 'elements') AS individual_element
FROM Table1
I have 30 different tables on which I need to run this query but not sure how to do that in postgres (using pgAdmin4). Is this possible? Please help.
Thanks
-MS

Orientdb - query in multiple databases

I need create a query using multiples Orientdb Databases.
Ex:
I tried something like that in database1.
select from vertex1 where field1 in ( select field2 from database2:vertex2)
Is It possibly create a SQL query in OrientdbDB using multiples database?

Querying PostgreSQL view via presto

I'd like to query postgresql view via presto. I've found some old links/notes that it should be possible. Unfortunately I don't have any views listed in SHOW TABLES command and when I tried to query data select cnt from umcount I got Table 'public.umcount' not found. How to query views then?
I'm using Presto 0.205
You can try out these queries first:
show schemas from <connector_name>
show tables from <connector_name>.<schema_name>
If everything works fine then use these prefixes in your select queries.
For example:
select * from <connector_name>.<schema_name>.<table_name> limit 10

Is there an equivalent to Oracle's user_role_privs view in Postgres?

Am trying to fetch information in Postgres equivalent to Oracle's user_role_privs.
select username,granted_role,admin_option from user_role_privs
I tried all the below views in Postgres but couldn't find the desired one
information_schema.role_table_grants
pg_roles;
pg_class;
pg_user
pg_catalog.pg_auth_members;
Can anyone suggest which view should be used to get username, granted_role and admin_option in Postgres?
You are looking for the pg_auth_members system catalog that contains relationships between roles (which feature as both users and groups in PostgreSQL).
To get the names of the users and roles, join with the pg_roles system catalog.

How to list tables from accessible via database links?

I have an access to a database, and sure I can get all tables/columns accessible for me just using:
select * from ALL_TAB_COLUMNS
I can also access some tables using "#", as I understand a database link mechanism, like this:
select * from aaa.bbb_ddd#ffgh where jj = 55688
where aaa.bbb_ddd#ffgh corresponds to some table with a column jj
BUT I don't see this aaa.bbb_ddd#ffgh table in ALL_TAB_COLUMNS.
How can I request all tables (and columns inside them) accessible for me via these database links (or so)?
You can't, easily, get all columns accessible via all database links; you can get all columns accessible via one database link by querying ALL_TAB_COLUMNS on the remote database
select * from all_tab_columns#<remote_server>
where <remote_server> in your example would be ffgh.
If you want to get this same information for all database links in your current schema, you'd either have to manually enumerate them and UNION the results together:
select * from all_tab_columns#dblink1
union all
select * from all_tab_columns#dblink2
Or, do something dynamically.
As Justin says, it's clearer if you add which database the data is coming from; you can do this either by just writing it in the query:
select 'dblink1' as dblink, a.* from all_tab_columns#dblink1 a
union all
select 'dblink2', a.* from all_tab_columns#dblink2 a
Or by using an Oracle built-in to work, for example the GLOBAL_NAME table (there's lots more ways):
select db1g.global_name, db1a.*
from all_tab_columns#dblink1 db1a
cross join global_name#dblink1 db1g
union all
select db2g.global_name, db2a.*
from all_tab_columns#dblink2 db2a
cross join global_name#dblink2 db2g