Description of functions and techniques for implementing Oracle databases in DB2

Source: Internet
Author: User

The following article describes how DB2 implements the functions of Oracle databases and summarizes its experience in actual operations, in this article, I will share with you some tips and experiences on implementing certain Oracle functions in DB2 ......

In practical applications, you may often encounter how to implement certain Oracle functions in DB2. Here I would like to briefly summarize that there may be many ways to implement a function. all are listed. You are welcome to continue, so that you can share with us, discuss and take a closer look! (the following mainly uses Oracle8I and DB2 7. X ).

1. How to Write Oracle and DB2 with the first n records in a table

Oracle can achieve this: Select * from user. bsempms where rownum <= n;

The DB2 implementation can also be like 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 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 db2admin. bsempms. dpt_no = db2admin. bsdptms. dpt_no;

6. Writing of Oracle and DB2 for external connections (right Outer Join, left Outer Join, full outer join, and combination Outer Join)

Oracle can achieve this: Select. * from bsempms a, bsdptms B where. dpt_no = B. dpt_no (+); Select. * from bsempms a, bsdptms B wherea. dpt_no (+) = B. dpt_no;

DB2 can achieve this ﹕

 
 
  1. Select * from db2admin.bsempms right outer join db2admin.bsdptms on db2admindb2admin.bsempms.dpt_no=db2admin.bsdptms.dpt_no;  
  2. Select * from db2admin.bsempms left outer join db2admin.bsdptms on db2admindb2admin.bsempms.dpt_no=db2admin.bsdptms.dpt_no;  
  3. 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 DB2. I hope you will gain some benefits.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.