Query columns names from a table from another user

Custodio picture Custodio · Jun 7, 2012 · Viewed 9.8k times · Source

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!

Answer

DCookie picture DCookie · Jun 7, 2012
SELECT * 
  FROM ALL_TAB_COLUMNS
 WHERE OWNER='ANOTHERUSER' 
   AND TABLE_NAME='THE_TABLE';

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