MySQL and Oracle Difference Comparison 3 Functions
MySQL and Oracle Difference Comparison Function Three
Function
Number Category ORACLE MYSQL Comment
1 Numeric function round(1.23456,4) round(1.23456,4) Same as:
ORACLE: select round(1.23456,4) value from dual
MYSQL: select round(1.23456,4) value
2 abs(-1) abs( -1) Function: Take the absolute value of the current data
Usage: The usage of oracle and mysql is the same
mysql: select abs(-1) value
oracle: select abs(-1) value from dual
3 ceil(-1.001)) ceiling(-1.001) Function: Return the smallest integer not less than X
Usage:
mysqls: select ceiling(-1.001) value
oracle: select ceil(-1.001) value from dual
4 floor(-1.001) floor(-1.001) Function: Return the maximum integer value not greater than X
Usage:
mysql: select floor (-1.001) value
oracle: select floor(-1.001) value from dual
5 Max(expr)/Min(expr) Max(expr)/Min(expr) Function: Return the minimum or maximum value of expr. MIN() and MAX() can accept a string argument; in this
case, they will return the minimum or maximum string passed down.
Usage:
ROACLE: select max(user_int_key) from sd_usr;
MYSQL: select max(user_int_key) from sd_usr;
6 String function ascii(str) ascii(str) Function :Returns the ASCII code value of the leftmost character of the string str. If str is an empty string,
The return value is 0. If str is a NULL, the return value is also NULL.
Usage:
mysql:select ascii('a') value
oracle:select ascii('a') value from dual
7 CHAR(N,...) CHAR(N,...) Function: CHAR() interprets parameters in integer type and returns the characters
given by the ASCII code value represented by the integer. string. NULL values will be ignored.
Usage:
mysql:select char(97) value
oracle:select chr(97) value from dual
8 REPLACE( str,from_str,to_str) REPLACE(str,from_str,to_str) Function: All occurrences of the string from_str in the string str are replaced by to_str, and then the string is returned.
Usage:
mysql: SELECT REPLACE ('abcdef', 'bcd', 'ijklmn') value
oracle: SELECT Replace('abcdef', 'bcd', 'ijklmn') value from dual
9 INSTR('sdsq','s',2) INSTR('sdsq','s') The number of parameters is different
ORACLE: select INSTR('sdsq','s',2) value from dual (Required to start from position 2)
MYSQL: select INSTR('sdsq','s') value (start from the default position 1)
10 SUBSTR('abcd',2,2) substring ('abcd',2,2) Function names are different:
ORACLE: select substr('abcd',2,2) value from dual
MYSQL: select substring('abcd',2,2) value
11 instr('abcdefg','ab') locate('ab','abcdefg') The function names are different:
instr -> locate (note: the location of the substring of locate and the total string To exchange)
ORACLE: SELECT instr('abcdefg', 'ab') VALUE FROM DUAL
MYSQL: SELECT locate('ab', 'abcdefg') VALUE
12 length(str ) char_length() function names are different:
ORACEL: SELECT length('AAAASDF') VALUE FROM DUAL
MYSQL: SELECT char_length('AAAASDF') VALUE
13 REPLACE('abcdef', ' bcd', 'ijklmn') REPLACE('abcdef', 'bcd', 'ijklmn') Same as:
ORACLE: SELECT REPLACE('abcdef', 'bcd', 'ijklmn') value from dual
MYSQL : SELECT REPLACE('abcdef', 'bcd', 'ijklmn') value
14 LPAD('abcd',14, '0') LPAD('abcd',14, '0') Same as:
ORACLE: select LPAD('abcd',14, '0') value from dual
MYSQL: select LPAD('abcd',14, '0') value from dual
15 UPPER (iv_user_id) UPPER(iv_user_id) Same as:
ORACLE: select UPPER(user_id) from sd_usr;
MYSQL: select UPPER(user_id) from sd_usr;
16 LOWER(iv_user_id) LOWER(iv_user_id) Same as:
ORACLE: select LOWER(user_id) from sd_usr;
MYSQL: select LOWER(user_id) from sd_usr;
or
ISNULL(u.email_address) Function names are different (select according to different functions):
ORACLE: select u.email_address , nvl(u.email_address, 10) value from sd_usr u (if u.email_address=NULl, replace its value with 10 in DB)
MYSQL: select u.email_address, IFNULL(u.email_address, 10) value from sd_usr u (if u.email_address=NULl, the displayed result is 10, instead of replacing its value with 10 in the DB)
select u.email_address, ISNULL(u.email_address) value from sd_usr u (if u. If email_address is NULL, it will display 1
IF Statement format: (expr1, expr2, expr3) Description:
1. decode(condition, value 1, translation value 1, value 2, translation value 2,... value n, translation value n, default value)
The meaning of this function is as follows:
IF condition = value 1 THEN
RETURN (translation value 1)
ELSIF condition = value 2 THEN
RETURN (translation value 2)
... ...
ELSIF condition = value n THEN
RETURN (translation value n)
ELSE
RETURN (default value)
END IF
2. mysql If syntax Description
Function: If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL), the return value of IF() is expr2;
Otherwise, the return value is expr3. The return value of IF() is a numeric value or a string value, depending on the context in which it is located.
Usage:
mysql: SELECT IF(1>2,2,3);
19 Type conversion function TO_CHAR(SQLCODE) date_format/ time_format Function names are different
SQL> select to_char(sysdate,'hh24-mi-ss') from dual;
mysql> select date_format(now(),' %Y-%m-%d');
mysql> select time_format(now(),'%H-%i-%S');
20 to_date(str,format) STR_TO_DATE( str,format) Function names are different:
MYSQL: SELECT STR_TO_DATE('2004-03-01' , '%Y-%m-%d') VAULE
21 trunc(-1.002) cast(-1.002 as SIGNED) Function names are different:
ORACLE: select trunc(-1.002) value from dual
MYSQL:select cast(-1.002 as SIGNED) value
MYSQL:
Character set conversion: CONVERT(xxx USING gb2312)
Type The conversion is the same as SQL Server, but the type parameters are a little different: CAST(xxx AS type), CONVERT(xxx, type), the type must use the following types:
Available types
Binary, with The effect of binary prefix: BINARY
Character type, can take parameters: CHAR()
Date: DATE
Time: TIME
Date and time type: DATETIME
Floating point number: DECIMAL
Integer : SIGNED
Unsigned integer : UNSIGNED
22 TO_NUMBER(str) CAST("123" AS SIGNED INTEGER) Function names are different
MYSQL: SELECT CAST("123" AS SIGNED INTEGER) as value;
SIGNED INTEGER: signed integer
23 Date function SYSDATE now() / SYSDATE() Different writing methods:
MYSQL:select now() value
select sysdate() value
24 Next_day(sysdate,7) Customize a function: F_COMMON_NEXT_DAY(date,int) The function names are different:
MYSQL: SELECT F_COMMON_NEXT_DAY(SYSDATE(), 3) value from DUAL;
(3: refers to the index value of the week) return The specified date immediately following the next week
25 ADD_MONTHS(sysdate, 2) DATE_ADD(sysdate(), interval 2 month) Function names are different:
MYSQL: SELECT DATE_ADD(sysdate(), interval 2 month) as value from DUAL;
26 Subtract 2 dates (D1-D2) DATEDIFF(date1,date2) Function: Return the number of days between two dates.
Usage:
mysql: SELECT DATEDIFF('2008-12-30','2008-12-29') AS DiffDate
oracle: Directly subtract two dates (such as d1-d2=12.3 )
27 SQL function SQLCODE There is no corresponding function in MYSQL, but SQLException in JAVA. The getErrorCode() function can obtain the error number. Oracle's built-in functions SQLCODE and SQLERRM are specially used in the OTHERS processor to return Oracle's error code and error message respectively.
MYSQL: You can get the error code, error status and error message from JAVA
28 SQLERRM There is no corresponding function in MYSQL, but SQLException in JAVA. The getMessage() function can obtain the error message. Oracle's built-in functions SQLCODE and SQLERRM are specially used in the OTHERS processor to return Oracle's error code and error message respectively.
MYSQL: You can get the error code, error status and error message from JAVA
29 SEQ_BK_DTL_OPT_INT_KEY.NEXTVAL Automatic growth column In MYSQL, it is an automatic growth column. The following method is used to obtain the latest ID:
START TRANSACTION ;
INSERT INTO user(username,password)
VALUES (username,MD5(password));
SELECT LAST_INSERT_ID() INTO id;
COMMIT;
30 SUM(enable_flag ) SUM(enable_flag) Same as:
ORCALE: SELECT SUM(enable_flag) FROM SD_USR;
MYSQL: SELECT SUM(enable_flag) FROM SD_USR;
31 DBMS_OUTPUT.PUT_LINE(SQLCODE) None in MYSQL The corresponding method is to print in the console for testing and has no impact on migration. dbms_output.put_line can only display 255 characters per line. If it exceeds, an error will be reported

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA
