Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 774
Custodio Avatar asked Jun 07 '12 18:06

Custodio


People also ask

How can I get column names from another table in SQL?

You can use the select statement with the Information Schema to retrieve a table's columns from the news object or table. The following query will give the table's column names: SELECT column_name FROM INFORMATION_SCHEMA.

Which query can be used to retrieve the column name from the table table is given below?

We can verify the data in the table using the SELECT query as below. We will be using sys. columns to get the column names in a table. It is a system table and used for maintaining column information.

How do I get a list of column names in SQL Developer?

Best AnswerSELECT owner, column_nameFROM all_tab_columnsWHERE table_name = 'YOUR_TABLE_HERE'ORDER BY owner, table_name; You may wnat to add "AND owner =..." as the above query will return all tables/views that have the table_name 'YOUR_TABLE_HERE'. i.e. more than one owner can have a table/view of the same name.


1 Answers

SELECT * 
  FROM ALL_TAB_COLUMNS
 WHERE OWNER='ANOTHERUSER' 
   AND TABLE_NAME='THE_TABLE';

Should get you there if you have privileges on the table.

like image 139
DCookie Avatar answered Oct 23 '22 04:10

DCookie