The difference between mysql and oracle

serial number ORACLE MYSQL Notes
1 NUMBER int / DECIMAL DECIMAL is a structure like NUMBER(10,2) INT is NUMBER(10), which means integer;
MYSQL has many int types, tinyint mediumint bigint, etc., different int widths are different
2 Varchar2(n) varchar(n)  
3 Date DATATIME Processing of
date fields MYSQL date fields are divided into two types: DATE and TIME. The ORACLE date field only has DATE, which contains the year, month, day, hour, minute, and second information. The system time of the current database is SYSDATE, accurate to seconds, or a string is converted into a date function TO_DATE('2001-08-01','YYYY-MM-DD') year-month-day 24 hours:minutes:seconds format YYYY-MM-DD HH24:MI:SS TO_DATE() There are many more date formats , You can refer to ORACLE DOC. The date field is converted into a string function TO_CHAR('2001-08-01','YYYY-MM-DD HH24:MI:SS')

The mathematical formula of the date field is very different. MYSQL finds 7 days from the current time and uses DATE_FIELD_NAME > SUBDATE (NOW(), INTERVAL 7 DAY) ORACLE finds 7 days from the current time and uses DATE_FIELD_NAME > SYSDATE - 7;

Several functions to insert the current time in MYSQL are: NOW() function to `'YYYY-MM-DD HH:MM:SS' returns the current date and time, which can be directly stored in the DATETIME field. CURDATE() returns today's date in the format 'YYYY-MM-DD', which can be directly stored in the DATE field. CURTIME() returns the current time in the format of 'HH:MM:SS', which can be directly stored in the TIME field. Example: insert into tablename (fieldname) values ​​(now())

and the current time in oracle is sysdate
4 INTEGER int / INTEGER INTEGER is equivalent to int in Mysql
5 EXCEPTION SQLEXCEPTION  For details, please refer to 2.5 Mysql exception handling in <<2009001-eService-O2MG.doc>>
6 CONSTANT VARCHAR2(1) There is no CONSTANT keyword in mysql Migrating from ORACLE to MYSQL, all CONSTANT constants can only be defined as variables
7 TYPE g_grp_cur IS REF CURSOR; Cursor: there are alternatives in mysql For details, please refer to 2.2 Cursor Handling in <<2009001-eService-O2MG.doc>>
8 TYPE unpacklist_type IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER; Array: In mysql, use temporary table processing
or write logic directly into the corresponding code, and
directly process each value in the collection accordingly
For details, please refer to 2.4 Array Processing in <<2009001-eService-O2MG.doc>>
9 auto-incrementing sequence auto-increment data type MYSQL has an auto-increasing data type. When inserting a record, you do not need to operate this field, and the data value will be automatically obtained. ORACLE does not have an auto-incrementing data type, and an auto-incrementing serial number needs to be established. When inserting a record, the next value of the serial number should be assigned to this field.
10 NULL NULL Handling of null characters
MYSQL's non-empty fields also have empty content. If a non-empty field is defined in ORACLE, empty content is not allowed. According to the NOT NULL of MYSQL to define the ORACLE table structure, an error will occur when importing data. Therefore, when importing data, it is necessary to judge the null character. If it is NULL or a null character, it needs to be changed to a string of spaces.

 

Oracle与MySQL的区别:

1.在Oracle中用select * from all_users显示所有的用户,而在MYSQL中显示所有数据库的命令是show databases.对于我的理解,Oracle项目来说一个项目就应该有一个用户和其对应的表空间,而MYSQL项目中也应该有个用户和一个库。在ORACLE(db2也一样)中表空间是文件系统中的物理容器的逻辑表示,视图、触发器和存储过程也可以保存在表空间中。而MYSQL并没有使用表空间来进行管理。

2.查询当前所有的表。ORACLE: select * from tab,MYSQL:show tables.

3.改变连接用户(库)。ORACLE:conn 用户名/密码@主机字符串,MYSQL:use 库名。

4.显示当前连接用户(库)。ORACLE:show user,MYSQL:connect.

5.执行外部脚本命令。ORACLE:@a.sql,MYSQL:source a.sql.

一、函数的使用参数不同

Mysql支持多个字符串拼接:

CONCAT(str1,str2,…)

Oralce只支持两个字符串的拼接,若想拼接多个字符串可以嵌套使用concat

CONCAT(str1,str2)

二、参数中有Null的处理方式不同

Mysql:返回结果为连接参数产生的字符串。如有任何一个参数为NULL ,则返回值为 NULL。

Oralce:如有任何一个参数为NULL ,则返回值拼接后的字符串。 三、其它方面

Mysql:如果所有参数均为非二进制字符串,则结果为非二进制字符串。 如果自变量中含有任一二进制字符串,则结果为一个二进制字符串。 Oracle:如果CONCAT中连接的值不是字符串,Oracle会尝试将其转换为字符串 注:Oracle拼接字符串还可以使用"||",当参数为Null时,返回值拼接后的字符串。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325344399&siteId=291194637