二、实验 1.创建测试数据SAM@OCM11G >create table test_space(id int,name varchar2(10));Table created.SAM@OCM11G >insert into test_space values (1,"sam");1 row created.SAM@OCM11G >insert into test_space values (2," sam ");1 row created.SAM@OCM11G >insert into test_space values (3," sam ");1 row created.SAM@OCM11G >commit;Commit complete.2.查询数据发现问题,并做字符统计SAM@OCM11G >select * from test_space; ID NAME ---------- ---------- 1 sam 2 sam 3 samSAM@OCM11G >select id,length(name) from test_space; ID LENGTH(NAME) ---------- ------------ 1 3 2 5 3 83.使用trim去掉空格SAM@OCM11G >select id,length(trim(name)) from test_space; ID LENGTH(TRIM(NAME)) ---------- ------------------ 1 3 2 3 3 3SAM@OCM11G >update test_space set name=trim(name);3 rows updated.SAM@OCM11G >select * from test_space; ID NAME ---------- ---------- 1 sam 2 sam 3 sam4.检查(问题已处理)SAM@OCM11G >select id,length(name) from test_space; ID LENGTH(NAME) ---------- ------------ 1 3 2 3 3 3三、总结 一个小小的trim函数,真是难者不会,会者不难。通过这个小案例,我又多掌握了ORACLE的一个小功能,学习脚步不能停。好久没有发文了,再给自己一针强心剂。加油 Sam!Where there is a will, there is a way.更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12本文永久更新链接地址