sybase数据库和oracle数据库中字段中含有换行符的解决办法


        最近在做数据库从sybase到oracle的迁移工作,sybase数据库表bcp导出后,通过sqlldr导入到oracle数据库,然后oracle数据库通过spool按照sybase数据库bcp的格式导出,进行比对,看两边的文件是否一样。但是出现了一个问题,导致两边的文件不一样,什么问题了,因为某些表中的某些字段中存在换行符,在sybase中bcp导出时,为一行,oracle数据库spool导出为两行,导致最后用comm -3比较的时候两边文件不一样。那么查询字段中的值是否有换行符呢?

1. sybase查询表中字段是否有换行符的方法

--sybase数据库中 ,char(10)表示换行,char(13)表示回车
select   * from  tsysparameter  where c_valuebound like '%'||char(10)||'%' ; 或者: select * from tsysparameter where  charindex(char(10),c_valuebound) > 0; 注意:charindex是前面字符在后面字符是否存在,存在大于0;
也就是说在sybase数据库中用char(10)表示换行符,用char(13)表示回车。

2. oracle数据库查询表中字段是否有换行符的方法:

--oracle数据库中 ,chr(10)表示换行,chr(13)表示回车
select   * from  tsysparameter  where c_valuebound like '%'||chr(10)||'%' ; 或者: select  * from tsysparameter where  instr(c_valuebound,chr(10))>0;

也就是说在oracle数据库中用chr(10)表示换行符,用chr(13)表示回车。

3.sybase 和oracle数据库更新字段中换行符的方法:

-sybase update tsysparamester set  c_valuebound=str_replace(c_valuebound,char(10),'') where  charindex(char(10),c_valuebound) >0; --oracle
update tsysparamester set  c_valuebound=replace(c_valuebound,chr(10),'') where  instr(c_valuebound,chr(10)) >0;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM