Seven considerations for converting MySQL to Oracle

Source: Internet
Author: User


There are many application projects to note the seven major considerations for converting MySQL Into Oracle. At the beginning, MySQL Databases can basically meet various functional requirements. As the number of application users increases, the amount of data increases, mySQL gradually becomes overwhelmed: the connection is slow or even down, so there is a need for MySQL to switch to Oracle, and the application needs to be modified accordingly. The following are some considerations for converting MySQL to Oracle. Www.2cto.com 1. Automatically increasing data types process MySQL Data Types Automatically increasing. This field is automatically obtained without operation when inserting records. 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) is used, the maximum value is 999999 INSERT. INSERT this field value as the serial NUMBER name. NEXTVAL 2. mySQL can use double quotation marks to enclose strings. Oracle can only use single quotation marks to enclose strings. You must replace single quotes before inserting and modifying strings: replace all the existing single quotes with two single quotes. Www.2cto.com 3. Processing of SQL statements on pages the MySQL processes are relatively simple. Use 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 position, and only ROWNUM <100, not ROWNUM> 80 can be used. The following are two SQL statements (ID is the field name of the unique keyword) that have been analyzed: 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,...] www.2cto.com FROM TABLE_NAME WHERE Condition 1 order by condition 2) c) where numrow> 80 AND NUMROW <100) order by Condition 3; 4. Processing of long strings Oracle also has its special features. The maximum length of a string that can be operated during INSERT and UPDATE is less than or equal to 4000 single bytes. If you want to INSERT a longer string, use the CLOB type for the field to use the DBMS_LOB package that comes with Oracle. Before inserting a modification record, you must make a non-null and length judgment. If the field value cannot be blank or the field value beyond the length is exceeded, a warning should be given, and the last operation is returned. 5. the DATE Field Processing MySQL DATE Field is divided into two types: DATE and TIME. The Oracle DATE Field only contains DATE, which contains the information of year, month, day, hour, minute, and second. the system TIME of the current database is SYSDATE, accurate to seconds, or use a string to convert to the date type function TO_DATE ('1970-08-01 ', 'yyyy-MM-DD') year-month-day 24 hours: minute: Second format YYYY-MM-DD HH24: MI: SS TO_DATE () date type field converted into string function TO_CHAR ('2017-08-01 ', 'yyyy-MM-DD HH24: MI: ss ') the mathematical formulas for date fields vary greatly. For MySQL, use DATE_FIELD_NAME> SUBDATE (NOW (), INTERVAL 7 DAY) to locate DATE_FIELD_NAME> SYSDATE-7; www.2cto.com 6. empty Character Processing MySQL non-empty fields are also empty content, Oracle defines non-empty fields are not allowed to be empty content. The Oracle table structure is defined based on the not null value of MySQL. errors may occur when data is imported. Therefore, when importing data, you need to judge the NULL character. If it is NULL or NULL, you need to change it to a space string. 7. fuzzy comparison of strings MySQL can use the field name likeOracle or the field name like, but this method cannot use the index, and the speed is not fast. Use the string comparison function instr (field name, string)> 0 will get more accurate search result 8. in programs and functions, pay attention to the release of result sets and pointers after database operations are completed. The preceding considerations for converting MySQL to Oracle are for your reference.
 

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.