Get data type of field in select statement in ORACLE

后端 未结 7 1599
半阙折子戏
半阙折子戏 2020-12-25 13:04

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 
FR         


        
7条回答
  •  既然无缘
    2020-12-25 13:32

    I found a not-very-intuitive way to do this by using DUMP()

    SELECT DUMP(A.NAME), 
           DUMP(A.surname), 
           DUMP(B.ordernum) 
    FROM   customer A 
           JOIN orders B 
             ON A.id = B.id
    

    It will return something like:

    'Typ=1 Len=2: 0,48' for each column.

    Type=1 means VARCHAR2/NVARCHAR2
    Type=2 means NUMBER/FLOAT
    Type=12 means DATE, etc.

    You can refer to this oracle doc for information Datatype Code
    or this for a simple mapping Oracle Type Code Mappings

提交回复
热议问题