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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值