tags:

views:

80

answers:

3

For a table in oracle, I can query "all_tab_columns" and get table column information, like the data type, precision, whether or not the column is nullable.

In SQL Developer or TOAD, you can click on a view in the GUI and it will spit out a list of the columns that the view returns and the same set of data (data type, precision, nullable, etc).

So my question is, is there a way to query this column definition for a view, the way you can for a table? How do the GUI tools do it?

A: 

you can use the ANSI catalog views, should work for most RDBMs

select * 
from information_schema.columns c
join information_schema.tables t on c.table_name = t.table_name
where table_type = 'view'
SQLMenace
I don't think Oracle has these. Our Oracle install does not, and I couldn't find any reference for it...
sleske
+3  A: 

You can use user_tab_columns (or all_tab_columns and dba_tab_columns respectively) regardless if table_name refers to a view or a table.

René Nyffenegger
Wow, thanks for that. I swear I queried all_tab_columns where table_name=my view name and didnt get any results... I must have had a typo in my query or something, because I just tried it again and got results. Thanks!
rally25rs
+2  A: 

View columns appear in all_tab_columns, so you can query them just as you can tables.

Alex Poole