4

我有两种用户类型:

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,以及哪个字节?

ViewSYS.USER_COLL_TYPES不提供此类信息。sqlfiddle

4

1 回答 1

2

看一看all_coll_typesChar_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
于 2012-11-08T16:39:22.607 回答