• oracle 和 sqlserver sql语句的差别


    select创建表
        oracle: create table table2 as (select * from table1);
        sqlserver: select * into table2 from table1;


    递归查询
        oracle: connect by
            select ... from <TableName>
            where <Conditional-1>
            start with <Conditional-2>
            connect by <Conditional-3>
        sqlserver: cte
            ;with cte(id, name, pid, lvl) as
            (
                select t.*, 0 lvl from t where pid=0
                union all
                select t.*, cte.lvl+1 lvl from t, cte where t.pid = cte.id
            )
            select
                case
                    when lvl=0 then name
                    else REPLICATE(' ', lvl) + '└' + name
                end,
                id,
                pid
            from cte
            ;

    正则
        oracel: regexp_substr, regexp_like, regexp_instr, regexp_replace, regexp_count
        sqlserver: 木有

    子查询
        oracle:     select * from (select * from table1);
        sqlserver: select * from (select * from table1) t;

    组内排序(一致)
        oracle: row_number() over (partition by ... order by ...)
        sqlserver: row_number() over (partition by .. order by ...)


    查询结果插入(一致)
        insert into table1(col1, col2, col3) select col1, col2, col3 from table2;

    转载请注明出处:http://surfsky.cnblogs.com 

  • 相关阅读:
    PAT 甲级 1072 Gas Station (30 分)(dijstra)
    python flask框架学习(二)——第一个flask程序
    python flask框架学习(一)——准备工作和环境配置与安装
    【Beats】Filebeat工作原理(十七)
    【Beats】Filebeat介绍及使用(十六)
    Dapper简介
    Sequelize ORM
    StackExchange / Dapper
    TypeORM 简介
    Egg.js 是什么?
  • 原文地址:https://www.cnblogs.com/surfsky/p/2791766.html
Copyright © 2020-2023  润新知