Querying table names that belongs to another database - oracle

I would like to query all the table names that belongs to another database. I can query the contents of a table in another database using oracle links for example: select * from owner.tablename#another_database; but how do I select the owner name and table names of the tables in another database? Thank you.

SELECT * FROM user_tables#another_database;

Related

variable table name in Spring boot

I have tables like "operation_log_202001", "operation_log_202002", ...
(I know this table structure and system structure is so bad. But I have to maintain it.)
When I try to access the "user" table, I can connect to the "user" table easily because it doesn't have any variable part in the table name.
I tried to solve this problem as below.
#Query("select * from :table_name limit 20")
Flux<ReviewData> findAll(String table_name);
But the generated query is "select * from 'operation_log_202001' limit 20". I don't wanna it to append "'" to the table name.
May I ask how to solve this problem?
Create a view, you can change it in runtime and can be mapped to an entity.
Elaborate:
A Database stores informations in tables. Those informations can be aggregated into views using custom SQL-queries. Views can act like tables, and inside their aggregation-query you are able to change the query's table-names - this way the table-name is variable.
Try with database name before table name, example :
Select * from db_log.table_name limit 20;

In which table the schema's are stored?

Hello I am using Oracle 11g. I want to know in which table information about the schemas created is stored ?
You can find information about the users (owners of the schemas) from dba_users.
A more general useful view would be the dba_objects one.
Not exactly what you are looking for, but this query will return the name of the schemas with any object
select distinct owner from dba_objects

How to create a temporary table in ORACLE with READ ONLY access

I am using CREATE GLOBAL TEMPORARY TABLE script to create a temporary table in the oracle DB but its showing SQL Error: ORA-01031: insufficient privileges. I Want to create a temp table with Read only access. Plz help me out in this.
What we are trying to achieve is:
We have to create a table in the destination database which is always GreenPlum.
In source database(Oracle) we are getting a select query from the USER for example: "select * from ABC A join DEF D on A.Col1=D.col1" then we are creating TEMP TABLE(In case of Oracle) on top of it for example "CREATE GLOBAL TEMPORARY TABLE table101 AS (select * from ABC A join DEF D on A.Col1=D.col1)".
Then using this TEMP table we get the required information from INFORMATION_SCHEMA for example "select * from ALL_TAB_COLUMNS where table_name='table101' ".By this we will get the column_name,data_type,character_maximum_length etc information. Using this information we can get "create table Statement" using Javascript .
Then we store this Create table statement in a variable & run it in Execute Row script(Step in pentaho data integration tool) which will create the Table in the destination DB.
Problem is that we have read only access in oracle. now what to do.
NOTE: In short, we are creating a table in the destination DB using the select statement from the source DB. Means structure of the table in Dest DB depends on the select query in Source DB.
If the target database is also an oracle database then you should be able to set up a database link there to the source database and use a "CREATE TABLE AS SELECT * FROM +source table+#+database link+;"
Whoops, I just noticed that this is from 2014. Oh well, maybe it well help future inquirers.

how to select data from two tables of different databases using dblinks in oracle?

i have a table t1 in database A and another table t2 in another database B.
how can we select data from them without using qualifiers directly..
just as database1.table1.something.
You should be able to query it with fully qualified names such as SCHEMA.TABLE#DBLINK.
If you don't want to use the #DBLINK notation while querying from database A you can mask the #DBLINK in a view (In database A) and query that view instead.
CREATE OR REPLACE VIEW remote_table [(column_list)]
AS select * FROM SCHEMA.TABLE#DBLINK;

Query columns names from a table from another user

Sounds pretty easy query the column names from a table, right? Indeed there is a answer to this question How can I get column names from a table in Oracle?
The main issue is that the table belongs to another user. My user is just for integration and I don't have any database privileges.
So I'm able to do some query like: SELECT * FROM anotherUser.THE_TABLE;
But something like SELECT * FROM USER_TAB_COLUMNS return no rows.
Perhaps I can create queries over all_tab_columns, Are there another faster options without procedures?
*It´s a oracle database!
SELECT *
FROM ALL_TAB_COLUMNS
WHERE OWNER='ANOTHERUSER'
AND TABLE_NAME='THE_TABLE';
Should get you there if you have privileges on the table.

Resources