One of the differences between MySQL and Oracle is the data type mysqloracle

Source: Internet
Author: User

One of the differences between MySQL and Oracle is the data type mysqloracle

Data Type

No. ORACLE MYSQL Note
1 NUMBER Int/DECIMAL DECIMAL is a structure such as NUMBER (). INT Is NUMBER (10), which indicates an integer;
MYSQL has many int-type classes, such as tinyint mediumint bigint. Different int widths are different.
2 Varchar2 (n) Varchar (n)  
3 Date DATATIME Processing of date fields
Mysql date fields are divided into DATE and TIME. The oracle date field is only DATE, which contains information about the 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 () has many date formats. For more information, see oracle doc. convert a datetime field to a string function TO_CHAR ('2017-08-01 ', 'yyyy-MM-DD HH24: MI: ss ')

The mathematical formulas for date fields vary greatly. MYSQL uses DATE_FIELD_NAME> SUBDATE (NOW (), INTERVAL 7 DAY) to locate the current time seven days from the current time and uses DATE_FIELD_NAME> SYSDATE-7;

The following functions Insert the current time in MYSQL are: NOW () function returns the current date time with ''yyyy-MM-DD HH: MM: s'', which can be saved directly to the DATETIME field. CURDATE () returns today's DATE in 'yyyy-MM-DD 'format and can be saved directly to the DATE field. CURTIME () returns the current TIME in 'hh: MM: ss' format and can be saved directly to the TIME field. Example: insert into tablename (fieldname) values (now ())

In oracle, the current time is sysdate.
4 INTEGER Int/INTEGER In Mysql, INTEGER is equivalent to int.
5 EXCEPTION SQLEXCEPTION For more information, see <2009001-eService-O2MG.doc> 2.5 Mysql Exception Handling
6 CONSTANT VARCHAR2 (1) Mysql does not have the CONSTANT keyword From ORACLE to MYSQL, all CONSTANT constants can only be defined as variables
7 TYPE g_grp_cur is ref cursor; Cursor: there are alternative solutions in mysql For more information, see <2009001-eService-O2MG.doc> 2.2 cursor Processing
8 TYPE unpacklist_type is table of VARCHAR2 (2000) index by BINARY_INTEGER; Array: using temporary tables in mysql
Or directly write the logic to the corresponding code,
Directly process each value in the Set
For details, see "2.4 Array Processing" in <2009001-eService-O2MG.doc>.
9 Auto-increasing sequence Automatically increasing data types 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.
10 NULL NULL Processing of null characters
Non-empty fields in MYSQL are also empty. empty fields are not allowed in ORACLE. 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.

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.