Comparison between Oracle and Mysql

1 Introduction

I use Oracle a lot in my work. But there is also a lot of daily practice with MySQL. I plan to write a series to list all the techniques and methods encountered in the use of Oracle. Including stored procedures, triggers PLSQL, strategies, temporary tables. Follow up slowly

2. Compare the difference

1. It is the most commonly used port: MySQL 3306 Oracle 1521
2. The command line when logging in
MySQL mysql -u user -p password -P port number -D database name
Oracle sqlplus user/password@ip:port/instance_name.
Oracle has the following types

sqlplus sys/sys as sysdba
sqlplus scott/tiger@192.168.10.145/orcl 普通用户登录
sqlplus scott/tiger@oracle_0913  服务名
sqlplus scott/tiger

3. The default user of mysql is root, and the user can create multiple databases, and each database can have multiple tables. Generally, the default user is used and multiple users will not be created;
oracle is a single instance, and there are Multiple users, different users have multiple tables.

  • What does this mean? For development, the understanding is that the daily operation of MySQL is the database, and how the database is created. But Oracle has only one database. Then the daily operation is the table created by the user. When you are a beginner, it is easy for users to be confused with the database, and you need to understand the concept clearly.
  • MySQL also has users, but the concept of users here does not involve tables, but only involves permissions and the like

4. The types of table fields are different
①mysql’s integer types include single-byte tinyint, double-byte smallint, three-byte mediumint, four-byte int or integer, eight-byte bigint, and floating-point types have four bytes float and eight-byte double, the date types include date, time, year, datetime, timestamp, and the character types include char, varchar, and text.

②The numerical type of oracle is number, the character type is char, varchar, varchar2, and the date type is date.

  • The number type in oracle is very particular. two parameters. precision and decimals. The daily amount is to use number(18,2);
  • In some cases, you can use blobs and the like to store some large files. It is to store the file in the database, of course, it is generally not recommended, and it is recommended to put it on the file server
5. The space used for installation is different. oracle takes up more space. A few G. MySql occupies hundreds of megabytes,

6. Processing of single quotes
In Mysql, you can use "double quotes" to wrap strings, but in Oracle, you can only use "single quotes" to wrap strings.
7. Automatic growth data type processing
①Mysql is an automatic growth data type, insert When the data is used, it does not need to be managed, it will automatically grow
②Oracle does not support the automatic growth data type, and the automatic growth is completed by establishing an automatic growth sequence number.
8. Transaction submission level
There are four isolation levels:
read uncommitted,
read committed
, repeatable read ,
serializable
Oracle has two transaction isolation levels:
① READ COMMITTED: read committed,
② SERIALIZABLE: serial read

  • The default isolation level of MySQL is higher than that of Oracle. It is reflected in daily development. After oracle development changes the data, you need to submit the data manually.
  • In order to improve concurrency, MySQL has an mvcc multi-version concurrency mechanism, and there are many things to talk about

9. The difference between temporary tables

In MySQL, temporary tables are database objects that are only visible to the current user session, and these tables are automatically dropped once the session ends.
Temporary tables are defined slightly differently in Oracle than in MySQL, in that once created temporary tables exist until they are explicitly dropped and are visible to all sessions with appropriate privileges. However, data in temporary tables is only visible to the user session that inserted the data into the table, and the data may persist across transactions or user sessions.
10. Backup process
Oracle provides different types of backup tools, such as cold backup, hot backup, export, import, data pump. Oracle provides the most popular backup utility called Recovery Manager (RMAN). Using RMAN, we can automate our backup schedules and restore databases with very few commands or stored scripts.

MySQL has mysqldump and mysqlhotcopy backup tools. There is no utility like RMAN in MySQL.
11. Long string processing
Oracle also has its special place in the processing of long strings. The maximum operable string length for INSERT and UPDATE is less than or equal to 4000 single characters,

If you want to insert a longer string, please consider using the CLOB type for the field, and the method borrows the DBMS_LOB package that comes with ORACLE. Before inserting and modifying records, it is necessary to make non-null and length judgments. Field values ​​that cannot be empty and values ​​exceeding the length should be warned and return to the last operation.
12. Oracle sequence
The primary key value in the database table sometimes we will use the numeric type and self-increment. In this way, both mysql and sql server can use tools to create tables, which is easy to implement. However, there is no self-increment method in oracle. In general, we will use sequences and triggers to implement the primary key auto-increment function.

-- Create sequence 
create sequence SEQ_TEST
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
cache 20;
CREATE SEQUENCE sequence //创建序列名称
[INCREMENT BY n] //递增的序列值是 n 如果 n 是正数就递增,如果是负数就递减 默认是 1
[START WITH n] //开始的值,递增默认是 minvalue 递减是 maxvalue
[{MAXVALUE n | NOMAXVALUE}] //最大值  
[{MINVALUE n | NOMINVALUE}] //最小值
[{
   
   CYCLE | NOCYCLE}] //循环/不循环
[{CACHE n | NOCACHE}];//分配并存入到内存中

Guess you like

Origin blog.csdn.net/qq_21561833/article/details/130901561