zoukankan      html  css  js  c++  java
  • Oracle Functions转成Ms-Sql procedure

    最近公司的一些Oracle项目要转到Ms_sql上,在把Oracle Functions改成MS-Sql的Procedure时,遇到了翻译的问题。

    罗列出这些问题:

    一、Oracle 基本类型

    oracle mssql
    varchar2 varchar
    number int
    number(15,2) decimal(15,2)

    二、序列。

    Oracle中的序列,我本来打算用自增列加一些小手段处理的,后来在同事的提醒下,才知道ms-sql2012的新特性也包含序列。

    附上简单的sql语句

    create sequence dbo.Sequence_voucher
    as int
    start with 1
    Increment by 1

    建一个序列,从1开始,每次加1

    查看序列:select * from sys.sequences

    具体测试细节,附上传送门:

    http://www.cnblogs.com/CareySon/archive/2012/03/12/2391581.html

    http://www.cnblogs.com/QinQouShui/p/3740707.html

    三、for update。

    例子:select NVL(id,-1) into v_id from student where id = 3 for update;

    这个是锁表相关的用法。

      1 select * from TTable1 for update 锁定表的所有行,只能读不能写
      2 select * from TTable1 where pkid = 1 for update 只锁定pkid=1的行
      3 select * from Table1 a join Table2 b on a.pkid=b.pkid for update 锁定两个表的所有记录
      4 select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update 锁定两个表的中满足条件的行
      5. select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update of a.pkid 只锁定Table1中满足条件的行
      for update 是把所有的表都锁点 for update of 根据of 后表的条件锁定相对应的表
    select * from emp where empno = 7369 for update; 会对表中员工编号为7369的记录进行上锁。其他用户无法对该记录进行操作,只能查询。select * from emp where empno = 7369 for update of sal; 这条语句是不是意味着只对表中的7369 这一行的sal字段的数据进行了上锁,其他数据则可以被其他用户做更新操作呢。学员测试结果为二条语句的效果是一样的。

    在对多个表进行锁定时for update of才会起作用,用户1进行如下操作(of 后面可以使table1中任意字段):

    select * from table1 a, table2 b where a.filed1 = b.filed1
    for update of a.filed1 ;

    用户2进行如下操作时可以对table2进行锁定,因为用户1只对table1进行了锁定:

    select * from table2 b
    for update

    传送门:http://blog.csdn.net/indieinside/article/details/13296695

  • 相关阅读:
    ng -v 不是内部或外部命令
    更改package.js后重新加载
    表格添加滚动条
    eclispse指针变成十字型
    清除输入框缓存数据
    用cd 命令进入和退出D盘文件夹的操作步骤。
    npm ERR! cb() never called! npm ERR! This is an error with npm itself. Pleas
    离开电脑时锁定电脑
    slice
    golang之字符串
  • 原文地址:https://www.cnblogs.com/SunnyZhu/p/5505809.html
Copyright © 2011-2022 走看看