Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle: Is there a way to get the column data types for a view?

Tags:

oracle

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?

like image 637
CodingWithSpike Avatar asked May 04 '10 14:05

CodingWithSpike


People also ask

How do I get column data type?

You can get the MySQL table columns data type with the help of “information_schema. columns”. SELECT DATA_TYPE from INFORMATION_SCHEMA. COLUMNS where table_schema = 'yourDatabaseName' and table_name = 'yourTableName'.

How do you change the datatype of a column in view in Oracle?

You can not change the column data type of the VIEW. Instead, you can change the data type of underlying base table's column (In that case refer the answer of the link mentioned in your question) or you can create a view query with that data type. -- Your view CREATE OR REPLACE VIEW <YOUR VIEW> AS SELECT ID, ...

How do I find the datatype of a column in Toad?

Use dba_tab_cols/user_tab_cols/all_Tab_cols to find it. select * from dba_tab_cols where table_name = 'XYZ'; In TOAD, use F4 on the table and find it.

How do you determine the datatype of a variable in Oracle?

you can use the function DUMP that gives a data type (as a number). The corresponding name is given via Oracle documentation (just look in the doc at the function DUMP).


2 Answers

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.

like image 99
René Nyffenegger Avatar answered Sep 17 '22 14:09

René Nyffenegger


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

like image 43
Alex Poole Avatar answered Sep 16 '22 14:09

Alex Poole