zoukankan      html  css  js  c++  java
  • 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;
  • 相关阅读:
    计算机专业术语中英对照
    PhpStorm如何下载github上的代码到本地
    PDO学习
    Shell中特殊的变量
    Shell中变量的使用
    修改cmd的字体
    Shell的输入输出
    Shell入门第一课
    设计模式--观察者(Observer)
    eclipse中使用git提交代码到github
  • 原文地址:https://www.cnblogs.com/jasmine-Jobs/p/7275115.html
Copyright © 2011-2022 走看看