• mysql和oracle在分页 长字符串上的区别


    mysql中有个分页的关键字   limit

    select * from table limit 10,5;//mysql里面这样是从10之后检索5条

    11 12 13 14 15

    分页公式:limit (PageIndex-1)*pageSize,pageSize 页面大小为6 第3页

    select * from table  limit 12,6

     oracle没有专门的关键字实现分页  靠 rownum(伪列)标明位置

    对于 Oracle 的 rownum 问题,很多资料都说不支持>,>=,=,between...and,只能用以上符号(<、<=、!=),并非说用>,& gt;=,=,between..and 时会提示SQL语法错误,而是经常是查不出一条记录来,还会出现似乎是莫名其妙的结果来(这段话非原创)

    select * from emp where rownum<=2;//查出前两条数据
    select * 
    from 
           ( select rownum as rn, t.* from emp t where rownum<=2 )
    where rn=2 ;//查出第二条数据

    select MyGrade.*

      from (select G.*, rownum rn

              from (select g.* from grade g order by chinese) G ) MyGrade

     where MyGrade.rn >= 10;//10条之后的

    select MyGrade.*

      from (select G.*, rownum rn

              from (select g.* from grade g order by chinese) G

             where rownum <= 10) MyGrade

     where MyGrade.rn >= 6;//6到10条

    3、显示第三页的5条记录
    当前所在页(currentPage)为3;
    每页显示的记录长度(lineSize)为temp;

    SELECT *
      FROM (SELECT rownum rb, emp.* from emp where rownum <= 15) temp
     WHERE temp.rb > 10

    pageIndex   pageSize

    select *

    from(select rownum rn,emp.* from emp where rownum<=pageIndex*pageSize) temp

    where temp.rn>(pageIndex-1)* pageSize

    长字符串的处理:

    Oracle有它独特的地方,数据类型有一个clob类型,此类型专门用于在insert或者update时候字符串长度大于等于4000个单字节时使用。所以在插入记录前一定要进行非空和长度的判断,不能为空的或者长度超出的都应该提出警告,返回上次操作。MySql就没有这样的数据类型。

  • 相关阅读:
    yun rpm
    Codeforces Round #375 (Div. 2) D. Lakes in Berland (DFS或并查集)
    51nod 1276 1276 岛屿的数量 (很好玩的题目
    玄学C语言之scanf,printf
    51nod 算法马拉松17 解题报告 以后不能赛中写题解(查逐梦者抄袭本人代码...
    51Nod 1007 正整数分组 -简单DP
    算法马拉松13 A-E解题报告
    十五天集训_
    贴一发STL源码
    省赛反思以及未来提高计划
  • 原文地址:https://www.cnblogs.com/yxj808/p/13367934.html
Copyright © 2020-2023  润新知