17,381
社区成员




--也可以用借助cast 加销空格函数trim来达到目的
SQL> create table tbb as select cast(trim('111aa') as varchar2(10)) zf from dual
2 /
Table created
SQL> desc tbb
Name Type Nullable Default Comments
---- ------------ -------- ------- --------
ZF VARCHAR2(10) Y
SQL> select zf,length(zf) from tbb
2 /
ZF LENGTH(ZF)
---------- ----------
111aa 5
SQL> desc tab_char_bak
Name Type Nullable Default Comments
---- ------------- -------- ------- --------
ID NUMBER(10) Y
NAME VARCHAR2(100) Y
SQL>
SQL> create table tab_char
2 (id number(10),
3 name char(4));
Table created
SQL> insert into tab_char values(1,'1');
1 row inserted
SQL>
SQL> create table tab_char_bak
2 as
3 select id,rtrim(cast(name as varchar2(100))) name from tab_char;
Table created
SQL> select * from tab_char_bak where name='1';
ID NAME
----------- --------------------------------------------------------------------------------
1 1
SQL>