如何从您不拥有的 oracle 表中获取列信息(不使用 describe)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/450637/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get column info from oracle table you don't own (without using describe)?
提问by user36890
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:
如何获得他不拥有但已选择授予的表上的列信息?这是,不使用DESCRIBE table_name
. 考虑这个例子:
// 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?
有任何想法吗?这甚至可行吗?
回答by tuinstoel
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';
回答by Aif
Have a look on oracle data dictionary, it should help.
看看oracle data dictionary,它应该有帮助。
回答by Ashiq Ali
CONN HR/HR@HSD;
GRANT SELECT ON EMPLOYEES TO SCOTT;
CONN SCOTT/TIGER@HSD;
SELECT owner, column_name FROM all_tab_columns WHERE table_name = 'EMPLOYEES';