In practice, you may often encounter some functions that correctly implement Oracle in the DB2 database. Here I will briefly summarize that there may be many ways to implement a function. Not all of them are listed here. You are welcome to continue to share with us, discuss them together, and take the following steps as an example: (Oracle8I and DB2 7. X are used as examples ).
1. How to Write the Oracle and DB2 databases with the first n records
Oracle can achieve this ﹕
- Select * from user.bsempms where rownum<=n;
DB2 can achieve this ﹕
- Select * from db2admin.bsempms fetch first n rows only;
You can also use row_number () over () to implement it;
2. How to get the writing of Oracle and DB2 on the current date
Oracle can achieve this ﹕
- Select sysdate from dual;
DB2 can achieve this ﹕
- Select current timestamp from sysibm.sysdummy1;
3. How to connect Oracle and DB2 databases with Fields
Oracle can achieve this ﹕
- Select emp_no||emp_nam from bsempms; Select concat(emp_no,emp_nam) from bsempms;
DB2 can achieve this ﹕
- Select emp_no||emp_nam from db2admin.bsempms; select emp_no concat emp_nam from db2admin.bsempms;
4. How to query the Oracle and DB2 statements of the Table Structure
Oracle can achieve this ﹕
- Select sysdate from dual;
DB2 can achieve this ﹕
- Select current timestamp from sysibm.sysdummy1;
5. Writing of Oracle and DB2 for INNER JOIN
Oracle can achieve this ﹕
- Select a.* from bsempms a,bsdptms b where a.dpt_no=b.dpt_no;
DB2 can achieve this ﹕
- Select * from db2admin.bsempms inner join db2admin.bsdptms on db2admindb2admin.bsempms.dpt_no=db2admin.bsdptms.dpt_no;
6. Writing of Oracle and DB2 databases with external connections (right Outer Join, left Outer Join, full outer join, and combination Outer Join)
Oracle can achieve this ﹕
- Select a.* from bsempms a,bsdptms b where a.dpt_no=b.dpt_no(+); Select a.* from bsempms a,bsdptms b wherea.dpt_no(+)=b.dpt_no;
DB2 can achieve this ﹕
- Select * from db2admin.bsempms right outer join db2admin.bsdptms on db2admindb2admin.bsempms.dpt_no=db2admin.bsdptms.dpt_no;
- Select * from db2admin.bsempms left outer join db2admin.bsdptms on db2admindb2admin.bsempms.dpt_no=db2admin.bsdptms.dpt_no;
- Select * from db2admin.bsempms full outer join db2admin.bsdptms on db2admindb2admin.bsempms.dpt_no=db2admin.bsdptms.dpt_no;
The above content is an introduction to the implementation of Oracle-related functions in the DB2 database. I hope you will have some gains.