日期:2014-05-16  浏览次数:20533 次

oracle db2命令对比(整理中)

1).如何取一表前n笔记录的Oracle和DB2的写法
? Oracle: select * from table_a where rownum<=100;
? DB2: ?? select * from table_a fetch first 100 rows only;

?

2).如何取得当前日期的Oracle和DB2的写法
? Oracle:select sysdate from dual;
? DB2:select current timestamp from sysibm.sysdummy1;

?

3).如何连接字段的Oracle和DB2的写法
Oracle : select emp_no||emp_nam from bsempms; Select concat(emp_no,emp_nam) from bsempms;

DB2: Select emp_no||emp_nam from db2admin.bsempms; select emp_no concat emp_nam from db2admin.bsempms;

?

4).如何查询表的结构的Oracle和DB2的写法
? Oracle: select sysdate from dual;
? DB2: select current timestamp from sysibm.sysdummy1;

?

5).内连接INNER JOIN的Oracle和DB2的写法
? Oracle: select a.* from bsempms a,bsdptms b where a.dpt_no=b.dpt_no;
? DB2:select * from db2admin.bsempms inner join db2admin.bsdptms on db2admin.bsempms.dpt_no=db2admin.bsdptms.dpt_no;

?

6).外连接的Oracle和DB2的写法(右外连接,左外连接,完全外连接,组合外连接)
? Oracle: select a.* from bsempms a,bsdptms b where a.dpt_no=b.dpt_no(+);
????????????? select a.* from bsempms a,bsdptms b where a.dpt_no(+)=b.dpt_no;

? DB2:?

select * from db2admin.bsempms right outer join db2admin.bsdptms on db2admin.bsempms.dpt_no=db2admin.bsdptms.dpt_no;


select * from db2admin.bsempms left outer join db2admin.bsdptms on db2admin.bsempms.dpt_no=db2admin.bsdptms.dpt_no;


select * from db2admin.bsempms full outer join db2admin.bsdptms on db2admin.bsempms.dpt_no=db2admin.bsdptms.dpt_no;

?

7)minus

select a,b from table_a
minus
select a, b from table_b

select a,b from table_a
except
select a, b from table_b

?

。。。

?

继续阅读:

http://blog.csdn.net/wwxtu24/article/details/5386254

?

?