Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get column info from oracle table you don't own (without using describe)?

Tags:

oracle

How would one get columns information on table which he doesn't own, but has select granted? This is, without using DESCRIBE table_name. Consider this example:


// user bob owns table STUDENTS
grant select on students to josh;
// now josh logs in, normally he would do
describe bob.students;
// but he's looking for something along the lines
select column_name from user_tab_columns where table_name = 'STUDENTS';
// which doesn't work, as josh doesn't own any tables on his own

Any ideas? Is this even doable?

like image 224
user36890 Avatar asked Jan 16 '09 14:01

user36890


2 Answers

select column_name from all_tab_columns where table_name = 'STUDENTS';

edit: or, even better

select owner, column_name from all_tab_columns where table_name = 'STUDENTS';
like image 161
tuinstoel Avatar answered Nov 03 '22 13:11

tuinstoel


Have a look on oracle data dictionary, it should help.

like image 24
Aif Avatar answered Nov 03 '22 12:11

Aif