Search code examples
sqloracleplsqloracle11gobject-type

how to get list of columns of an record type or list of columns for an Object type in Oracle


If we create an object type or recrod type like below

create type t_data as object(
 execId varchar2(500),
 description varchar2(500)
 );
 /

then how to get the list of columns for this type at later point?. In case of tables we could use all_tab_columns to get similar list.


Solution

  • You can use user_type_attrs:

    SELECT * 
    FROM user_type_attrs
    WHERE TYPE_NAME = 'T_DATA';
    

    Column ATTR_NAME is what you are looking for.

    Here is a demo