Precautions for migrating a program from MySQL to Oracle

Source: Internet
Author: User

1. Automatically increasing data type Processing

MySQL has a data type that increases automatically. When you insert a record, you do not need to operate on this field. The data value is automatically obtained. Oracle does not have an auto-increasing data type. You need to create an auto-increasing serial number. When inserting a record, you need to assign the next value of the serial number to this field.

Create sequence serial number name (preferably table name + Serial number mark) increment by 1 start with 1 maxvalue 99999 cycle nocache;

The maximum value is determined by the length of the field. If the defined auto-increment serial number (6), the maximum value is 999999.

Insert statement insert this field value: name of the serial number. nextval

2. Single quotes

MySQL can use double quotes to enclose strings. Oracle can only use single quotes to enclose strings. You must replace single quotes before inserting and modifying strings: replace all the existing single quotes with two single quotes.

3. Processing of paging SQL statements

The SQL statement for MySQL to process paging is relatively simple. It uses limit to start the position and record the number. In PHP, you can also use seek to locate the result set. It is complicated for Oracle to process paging SQL statements. Each result set has only one rownum field to indicate its location, and only rownum <100, not rownum> 80 can be used.

The following two SQL statements (ID is the field name of the unique keyword) are better after analysis ):

Statement 1:

Select ID, [field_name,...] from table_name where ID in (select ID from (select rownum as numrow, ID from table_name where Condition 1 order by condition 2) Where numrow> 80 and numrow <100) order by Condition 3;

Statement 2:

Select * from (select rownum as numrow, C. * From (select [field_name,...] from table_name where Condition 1 order by condition 2) c) Where numrow> 80 and numrow <100) order by Condition 3;

PDM Chinese website www.pdmcn.com

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.