最近在做数据的迁移,再将数据从mysql迁移至oracle时,部分sql语句进行了修改,在此对部分知识点进行记录:

参考资料:https://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_substring-index

1、【mysql】find_in_set:

  语法:find_in_set(str,strList)  -----> Return the index position of the first argument within the second argument  

  功能:在字符串列表strList中查找字符串str,并返回str所在的索引位置。str要查找的字符串,strList以“,”分割的字符串。

  定义:

    1、Returns a value in the range of 1 to N if the string str is in the string list strlist consisting of N substrings.

      如果字符串str在由N个字符串组成的字符串列表strlist内,则返回1到N范围内的值。

    2、A string list is a string composed of substrings separated by , characters.

      字符串列表是由字符串分隔的子字符串组成的字符串。

    3、If the first argument is a constant string and the second is a column of type SET, the FIND_IN_SET() function is optimized to use bit arithmetic.

         如果第一个参数是常量字符串,第二个参数是SET类型的列,则FIND_IN_SET()函数被优化以使用位运算 

    4、Returns 0 if str is not in strlist or if strlist is the empty string.

      如果字符串str不在字符串列表strlist内或者字符串列表strlist是空字符串,则返回0。

    5、Returns NULL if either argument is NULL.

      如果任意参数为null,则返回null。

    6、This function does not work properly if the first argument contains a comma (,) character.

      如果第一个参数包含了逗号(,)字符,则此函数无法正常工作。

  实际应用:

    某表中某字段值由两部分以“|”连接组成,如:A|B,A表示某C类型的编号,B表示某D类型的编号。

    在查询时,按C类型编号和D类型编号作为两种条件进行查询:

    在mysql中使用find_in_str(?,REPLACE('A|B','|',','))可实现查询,而在oracle中该函数没有,那我们可以换种方式:

    用oracle中的 REGEXP_SUBSTR(String, pattern, position, occurrence, modifier)函数 获取所需的部分 与条件值进行比对进行查询:

      如上述应用中可用 REGEXP_SUBSTR('A', '[^|]+', 1, 1) =? 作为C类型编号查询条件, REGEXP_SUBSTR('B', '[^|]+', 1, 2) =?作为D类型编号查询条件。

2、【mysql】substring_index (暂记录其中一种,其他后续补充)

  语法:substring_index(str,delim,count)  ------>Return a substring from a string before the specified number of occurrences of the delimiter

  功能:在指定的分隔符出现之前从字符串返回一个子字符串。str被截取的字符串,delim分隔符,count分隔符出现的次数。

  定义: 

    1、Returns the substring from string str before count occurrences of the delimiter delim. 

      在分隔符出现之前返回字符串str中的子字符串。

    2、If count is positive, everything to the left of the final delimiter (counting from the left) is returned.

      如果count为正数,则返回最终分隔符左侧的所有内容(从左侧计数)。即,从左边开始计数,获取第count个分隔符左侧的内容。

    3、If count is negative, everything to the right of the final delimiter (counting from the right) is returned.

      如果count为负数,则返回最终分隔符右侧的所有内容(从右侧计数)。即,从右边开始计数,获取第count个分隔符右侧的内容 。

    4、SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.

     SUBSTRING_INDEX()在搜索delim时执行区分大小写匹配。

  实际应用:

     某表中某字段值由两部分以“|”连接组成,如:A|B,A表示某C类型的编号,B表示某D类型的编号。

     在查询时,查询出C类型编号和D类型编号并进行展示:

     在mysql中,我们可以使用substring_index(str,delim,count)函数来实现该需求,而在oracle中,我们依然可以通过REGEXP_SUBSTR(String, pattern, position, occurrence, modifier) 来实现该需求

3.【mysql】UUID:

  在实际应用当中,有时我们会用到UUID()函数来实现唯一值。

  在mysql中我们可以使用:select replace(uuid(),'-','') as uuid; 来获取唯一值,而在oracle中,我们得使用:select lower(sys_guid()) as uuid  from dual;来获取

  

数据从mysql迁移至oracle时知识点记录(一)的更多相关文章

  1. 将数据从MySQL迁移到Oracle的注意事项

    将数据从MySQL迁移到Oracle的注意事项1.自动增长的数据类型处理MYSQL有自动增长的数据类型,插入记录时不用操作此字段,会自动获得数据值.ORACLE没有自动增长的数据类型,需要建立一个自动 ...

  2. 数据从mysql迁移到hbase的一些思考及设计

    一.进行迁移的原因 由于业务的发展,使用mysql进行建立索引进行搜索已经造成数据流的瓶颈卡在了数据库io,例如每次dump全表的时候,会造成压力过大,造成耗时很长,并且当前的数据量基本上已经达到了亿 ...

  3. mysql迁移oracle

    有很多应用项目, 刚起步的时候用MYSQL数据库基本上能实现各种功能需求,随着应用用户的增多,数据量的增加,MYSQL渐渐地出现不堪重负的情况:连接很慢甚至宕机,于是就有把数据从MYSQL迁到Orac ...

  4. MyBatis项目实战 快速将MySQL转换成Oracle语句

    一.前言 因项目需求,小编要将项目从mysql迁移到oracle中 ~ 之前已经完成 数据迁移 (https://zhengqing.blog.csdn.net/article/details/103 ...

  5. mysql迁移mpp数据库Greenplum

    1. 场景描述 因兄弟项目中mysql有点扛不住了,要做sql优化,但是业务有点小复杂,优化起来有点麻烦(sql嵌套有点多),便想着用Mpp数据库Greenplum测试下,看性能和复杂度怎么样,趟趟水 ...

  6. 使用Navicat迁移MySQL数据至Oracle时大小写原因报“表或视图不存在”问题处理

    使用Navicat提供的数据传输工具将JEECMSv9的MySQL的数据迁移至Oracle数据库,数据迁移成功表都存在,但是在程序启动时提示表或视图不存在. Caused by: java.sql.S ...

  7. mysql数据库迁移到oracle数据库后 如何删除相同的数据

    mysql数据库迁移到oracle数据库后 如何删除相同的数据 首先搞清楚有多少数据是重复的 select pid from product group by pid having count(pid ...

  8. 使用MySQL Migration Toolkit快速将Oracle数据导入MySQL[转]

    使用MySQL Migration Toolkit快速将Oracle数据导入MySQL上来先说点废话本人最近在学习一些数据库方面的知识,之前接触过Oracle和MySQL,最近又很流行MongoDB非 ...

  9. 使用MySQL Migration Toolkit快速将Oracle数据导入MySQL

    MySQL GUI Tools中的MySQL Migration Toolkit可以非常方便快捷的将Oracle数据导到MySQL中,该软件可以在http://dev.mysql.com/downlo ...

随机推荐

  1. tomcat1章1

    package ex01.pyrmont; import java.net.Socket; import java.net.ServerSocket; import java.net.InetAddr ...

  2. Codeforce 270A - Fancy Fence (正多边形)

    Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fe ...

  3. [转载]window.location.href的用法(动态输出跳转)

    无论在静态页面还是动态输出页面中window.location.href都是不错的用了跳转的实现方案   javascript中的location.href有很多种用法,主要如下. self.loca ...

  4. TestNG 搭建测试框架 自动化测试

    框架层级及基本组件:    参考:https://www.cnblogs.com/jier888/p/8998724.html Java作为开发语言 Maven管理项目及Jar包 Testng作为测试 ...

  5. Django框架----权限组件(具体代码实现)

    1.settings """ Django settings for day80 project. Generated by 'django-admin startpro ...

  6. Qt QTextEdit根据行号移动光标

    QTextEdit* p = new QTextEdit; QTextBlock block = p->document()->findBlockByNumber(nLineNum); p ...

  7. 在Eclipse中创建Dynamic Web Project具有和MyEclipse中Web Project一样的目录结构

    1.在Eclipse中新建Dynamic Web Project 1.1.修改default output folder build\classes修改为:WebRoot\WEB-INF\classe ...

  8. Prometheus监控学习笔记之PromQL简单示例

    0x00 简单的时间序列选择 返回度量指标 http_requests_total 的所有时间序列样本数据: http_requests_total 返回度量指标名称为 http_requests_t ...

  9. Linux FreeTDS的安装与配置

    Linux FreeTDS的安装与配置 一.简介 官方网站:http://www.freetds.org 版本:0.64 下载地址:http://ibiblio.org/pub/Linux/ALPHA ...

  10. 什么是ip地址,什么是私有地址

    ip地址链接:https://jingyan.baidu.com/article/f96699bbf23089894e3c1be7.html 私有地址链接:https://baike.baidu.co ...