zoukankan      html  css  js  c++  java
  • 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 

  • 相关阅读:
    c++好习惯
    mysql:表
    负载均衡
    KBEngine:架构
    skynet的一些运维数据
    Linux学习—LVM快照功能
    跳跃表
    SQL --Chater03 聚合与排序
    SQL --Chapter02 查询基础
    SQL---Chapter01 数据库和SQL
  • 原文地址:https://www.cnblogs.com/surfsky/p/2791766.html
Copyright © 2011-2022 走看看