Analyze the differences between db2 and oracle

Source: Internet
Author: User

After analyzing the differences between db2 and oracle, a system that has been developed for a period of time has been used on db2 and has finally been developed almost. There is no major problem in testing. Suddenly, a customer asked to use the oracle database at the scene. At the beginning, he thought there should be no problem. Although he had not tested the oracle database during development, it was nothing more than an SQL problem, as a result, oracle databases were dumpfounded as soon as they were released. I did not even have a function to run normally, and all the functions were blank pages. Of course, all the errors were SQL, but this is beyond my imagination! So let's record the problems we encountered. We should try to use SQL statements as much as possible in the future, and save the effort to migrate the SQL statements later. 1. Obtain the current system date. Db2 is current date, but this is not applicable in oracle. oracle is sysdate. None of the information I found indicates that db2 can use sysdate, but my db2 9.7 version can indeed use the sysdate function. So it's okay. All functions for getting the current date of the system are changed to sysdate, which is applicable to oracle and db2. 2. Date Field. For fields whose data type is date, you do not need to perform any processing during operations in db2. You can perform the same processing for fields of the varchar type. However, oracle cannot do this. During query, T0_CHAR (CLOMUN, 'yyyy-mm-dd') must be used, and TO_DATE (CLOMUN, 'yyyy-mm-dd') to 'date. The to_char and to_date functions can also be used in db2. 3. DECIMAL type in db2 and NUMBER type in oracle. DECIMAL in db2 corresponds to the NUMBER type in oracle to define the NUMBER type and retain several valid numbers. For example, number () (rounding) is defined in oracle. decimal () is defined in db2 (truncated directly ). The DECIMAL type cannot include null values. If it is null, 0 is inserted by default. If it is 10.00, it can be directly displayed after the query, however, the number type is only 10, so if you want to display 10.00, You Need To format it. In addition, the number type can be empty. 4. SQL differences. There are some SQL differences between db2 and oracle. This is inevitable, but most simple SQL statements are the same. Here are some examples: Query sequence oracle: select T18_ONLINE_TASKFACT_TASKKEY.currval from dual (current value) select T18_ONLINE_TASKFACT_TASKKEY.nextval from dual (next value) db2 select prevval for T18_ONLINE_TASKFACT_TASKKEY from sysibm. sysdummy1 (current value) select nextval for T18_ONLINE_TASKFACT_TASKKEY from sysibm. sysdummy1 (next value) queries the first 10 rows of Data db2: select * from test fetch first 10 rows onlyoracle: select * from test where rownum <= 10

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.