Oracle和mysql语句不一样点记录

1.主键自增
    (1)Mysql能够给表主键设置自增,添加数据时不须要设置id,数据库会自动设置id;
    (2)Oracle没有主键自增,若是须要设置自增,须要给表添加自增序列;
    添加数据时,从序列中取下一个值做为id;mysql


2.系统时间
    (1)Mysql中系统时间为now(),oracle中系统时间为sysdatesql


3.Like其后写法
    (1)Mysql写法:like CONCAT('%', #{title}, '%')
    (2)Oracle写法:like  '%'||#{title}||'%'  (oracle中contact只能连接两个参数)数据库


4.分页
    (1)Mysql写法:select * from table limit startindex , pagesize
    (2)Oracle写法:select * from (select * , rownum as rn from table) where rn between startindex , endindexoracle


5.时间条件
    (1)Mysql写法:where  create_date  &gt  #{beginDate}
    (2)Oracle写法:
    where  to_char(create_date , ’yyyy-MM-dd HH:mm:ss’)  &gt  #{beginDate}
    *传输的beginDate为字符串格式,mysql中能够直接使用时间字段进行比较,Oracle须要使用to_char函数把时间字段转换为必定格式的字符串函数

相关文章
相关标签/搜索