[SOLVED] Get data type of field in select statement in ORACLE

Issue

Can I get data types of each column I selected instead of the values, using a select statement?

FOR EXAMPLE:

SELECT a.name, a.surname, b.ordernum 
FROM customer a
JOIN orders b
ON a.id = b.id

and result should be like this

name    | NVARCHAR(100)
surname | NVARCHAR(100)
ordernum| INTEGER

or it can be in row like this, it isn’t important:

name           |   surname     |  ordernum
NVARCHAR(100)  | NVARCHAR(100) |   INTEGER

Thanks

Solution

You can query the all_tab_columns view in the database.

SELECT  table_name, column_name, data_type, data_length FROM all_tab_columns where table_name = 'CUSTOMER'

Answered By – abhi

Answer Checked By – Candace Johnson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.