Getting all tables from an oracle database - sql

I'm trying to retrieve a list of tables from an Oracle connection. I'm not very familiar with Oracle terminology and thus, having hard time finding the information I need.
Right now I can use Microsoft Access to connect via ODBC and it pops up with a "Link Tables" dialog that lists all tables, not just the ones I "own". None of the queries I've tried so far, give me this data.
I'm trying "SELECT * FROM all_tables" but that doesn't show me the right data.

ALL_TABLES will show you all the tables that you have access to SELECT from. DBA_TABLES will show you all the tables that exist in the database though you'll need an additional privilege grant to be able to query the DBA* data dictionary objects.

Try select * from all_tables, that should do what you want.

It can be.. (If user has dba role)
select * from dba_tables

SELECT owner, table_name
FROM all_tables

You can also try
SELECT * FROM USER_TABLES
It will return list of tables owned by your user.

SELECT * FROM TAB; that will show you all the table and views

Related

How to get count of tables present in a particular schema in snowflake?

I am trying to find the count of tables present in CDC schema, I tried with information_schema but the information_schema is empty for me.
The following SQL would give you the required results:
use schema <schemaname>;
show tables;
The result shows the number of tables in the schema.
Note: The information schema in a particular database only displays the objects to which your current role in the session has access.
Please make sure that the role you are using has required access control privileges to view the database objects. If not, if you have access to high privilege roles like SYSADMIN/ACCOUNTADMIN you could use them when viewing metadata information in Snowflake.
You can try querying the INFORMATION_SCHEMA.TABLES View with a query :
select count(distinct TABLE_NAME)
from <database_name>.INFORMATION_SCHEMA.TABLES
where TABLE_CATALOG = <database_name>
and TABLE_SCHEMA = <schema_name>;
Alternatively, you can also use the SHOW TABLES command as follows to get the count.
show tables in schema <DATABASE_NAME>.<SCHEMA_NAME>;
select count(*) from table(result_scan('<last_query_id>'));

How to list all selectable tables with current user in SAP HANA DB

I want to list all tables with current user using sql.
I know there are some way to get privileges, like EFFECTIVE_PRIVILEGES, but it only shows privileges which is granted by GRANT SELECT ~ on [TABLE] to [USERS].
You can query the schema information to get this - there's no SHOW TABLES or equivalent available.
Try:
SELECT TABLE_NAME FROM "SYS"."TABLES" WHERE SCHEMA_NAME='<database_name>'
which works for me.
You can also get Column Names in thsi way from the SYS.COLUMNS view

How can I see my tables in SQL Developer? [duplicate]

I am not sure why but I just installed SQLdeveloper 32 bit (3.0.0.4). When I click to expand the tables/views/indexes or etc it displays nothing at all!
But when I do the following:
SELECT owner, table_name
FROM dba_tables
I see the list of tables and I have read access to these tables since I can do a select * from anytable and data shows. Any thoughts?
The SQL Developer tree shows you what objects you own, not what objects you have access to. If you want to see the objects that you have access to that are owned by other users, you would need to navigate to the "Other Users" branch of the tree, then the user that owns the table, then the "Tables" branch.
Add select privilege to all_objects/user/ojects in the db user
Launch SQL Developer as administrator

How can I list all tables existent in a Database Link (Oracle)?

Basically I have a Database link (Oracle) called mylink.domain, in this link we can access foundation information like name of them members and other general information.
I would like to list all table's name in this link but i don't know how to do that.
Thanks in advance
You can access the all_tables view through the dblink:
select owner, table_name
from all_tables#dblink
order by owner, table_name;
Selecting the content of ALL_TABLES dictionary view will list you all tables your user has access to. Generally, it is not always possible to get a list of tables you dont have permissions for - they just do not show up. If your user has the SELECT ANY DICTIONARY priviledge, you can select the content of DBA_TABLES, which will always list all tables existing in the database.
select table_name from all_tables#dblinkname;
This shows all tables your linked user has access to.
Where I got the answer from

how to select a Oracle schema-specific view from another schema

Suppose I'm logged in as USERA, I want to access all the user_* views of the USERB schema, such as user_tables, user_tab_columns. How can I do this? Thanks
All the USER_* tables have analogues with the ALL_* and DBA_* prefix. USER_TABLES has information about all the tables you own. ALL_TABLES has information about all the tables you have access to. DBA_TABLES has information about all the tables in your database.
If you want to see information about UserB's tables
SELECT *
FROM all_tables
WHERE owner = 'USERB';
or
SELECT *
FROM dba_tables
WHERE owner = 'USERB';
The former will work if you have SELECT access on User B's tables. The latter will work if your DBA has given you access to the DBA_TABLES view. That is normally done by granting the SELECT ANY DICTIONARY privilege (or the SELECT_CATALOG_ROLE in prior version) though the DBA can grant access to individual DBA_* views.
USER_% views give what you own, that is what's inside your schema.
ALL_% views give what you have access to.
So what you really should use is ALL_TABLES/etc, and grant appropriate access to USERB objects.
Assuming you have permissions, you could try:
ALTER SESSION SET CURRENT_SCHEMA=USERB;