Question

I have two user types:

create type TEST_TYPE_WITH_CHAR as table of varchar2(100 char);
create type TEST_TYPE_WITH_BYTE as table of varchar2(100 byte);

How to determine what type contains char, and which byte?

View SYS.USER_COLL_TYPES does not provide such information. sqlfiddle.

Was it helpful?

Solution

Take a look at all_coll_types view. Char_used column, which tells you whether the length of varchar2 element is specified in bytes or characters is present only there:

SQL> create type t_coll_type is table of varchar2(10 byte);
  2  /

Type created

SQL> 
SQL> select type_name
  2       , elem_type_name
  3       , char_used
  4    from all_coll_types
  5  where type_name = 'T_COLL_TYPE'
  6  ;

TYPE_NAME                      ELEM_TYPE_NAME                 CHAR_USED
------------------------------ ------------------------------ ---------
T_COLL_TYPE                    VARCHAR2                       B

SQL> create type t_coll_type2 is table of varchar2(10 char);
  2  /

Type created

SQL> 
SQL> select type_name
  2       , elem_type_name
  3       , char_used
  4    from all_coll_types
  5  where type_name = 'T_COLL_TYPE2'
  6  ;

TYPE_NAME                      ELEM_TYPE_NAME                 CHAR_USED
------------------------------ ------------------------------ ---------
T_COLL_TYPE2                   VARCHAR2                       C
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top