• 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;
  • 相关阅读:
    python学习第四天 --字符编码 与格式化及其字符串切片
    Lambda表达式 之 C#
    python学习第三天 --布尔类型
    深入理解正则表达式
    《你不知道的JavaScript》第一部分:作用域和闭包
    jquery的extend和fn.extend
    HttpModule与HttpHandler详解
    jQuery分析(2)
    jQuery分析(1)
    jQuery源码中的“new jQuery.fn.init()”什么意思?
  • 原文地址:https://www.cnblogs.com/jasmine-Jobs/p/7275115.html
Copyright © 2020-2023  润新知