Oracle 与 SQL 兼容笔记

来源:互联网 发布:淘宝实名认证小号出售 编辑:程序博客网 时间:2024/06/07 00:21

此文用语载录开发过程中出现的Oracle与Sql Server在某些sql语句中不兼容的语法

 

  1. 语法: update [table name] set (Column1, Column2,.....) = (select Column1, Column2,.... from [table name].....): 在Sql Server中 可以使用 update tableA a set a.name = b.name, a.age = c.age from tableB b inner join tableC c on c.id = b.id where a.id = c.id, 但是在Oracle中会报错提示“ERROR: -933 - ORA-00933: SQL command not properly ended”,不支持在update后面inner join语法。 对于Oracle我们可以使用在set语句后使用子查询: set a.name = (select b.name from tableB b where b.id = a.id),但是当有多个字段需要update时,此做法可以替换为: set (a.name,a.age.....) = (select b.name,c.age.....from ....). 可能只是用到了update的不同语法,但是此方法仅适用Oracle.   所以当写update语句时,应根据不同数据库执行不同的update语句。
  2. Oracle默认用户为sys, Sql Server 为 sa
  3. case when, Sql Server could use "case when" but in Oracle, it use "decode" instead.
原创粉丝点击