我有两种用户类型:
create type TEST_TYPE_WITH_CHAR as table of varchar2(100 char);
create type TEST_TYPE_WITH_BYTE as table of varchar2(100 byte);
如何确定哪个类型包含char,以及哪个字节?
查看SYS.USER_COLL_TYPES不提供此类信息. sqlfiddle.
最佳答案 看看all_coll_types视图. Char_used列,它告诉您是否以字节或字符指定varchar2元素的长度仅存在于:
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