当前位置:网站首页>Syntax differences between MySQL and Oracle
Syntax differences between MySQL and Oracle
2022-07-24 05:48:00 【iamzhanchi】
MySQL and Oracle Grammatical differences
One 、 Data type differences
| Category | Oracle | MySQL | difference |
|---|---|---|---|
| date | Date | Date、Time、Datetime | MySQL in Date It only means year, month and day ,Time It only means hours, minutes and seconds ,Datetime It means year, month, day, hour, minute, second Oracle in Date It means month, day, hour, minute, second and MySQL in Datetime equally |
| On the column | Sequence | AUTO_INCREMENT | MySQL Set the auto increment key on the table to realize auto increment ,Oracle It is to build a maximum value of the initial value of the sequence through the sequence |
| … | … | … | … |
Two 、 Database operation differences
| Category | Oracle | MySql | difference |
|---|---|---|---|
| Parameter query | show parameter Parameters | show variables like ‘% Parameters %’ | |
| database | nothing | create database test_1;show databases; | MySQL You can create a database ,Oracle Just create instances , The user is in the instance , Or container database |
| … | … | … | … |
3、 ... and 、 Table operation difference
| Category | Oracle | MySQL | difference |
|---|---|---|---|
| Create table | create table emp{ emp_no number(10) primary key, -- Primary key …} | create table emp01{emp_no int(10) primary key AUTO_INCREMENT,– The primary key increases automatically …} | MySQL No, number, But you can grow your reputation (AUTO_INCREMENT),MySQL Yes double type .Oracle Self growth cannot be declared , Decimal only float type |
| Delete table | drop Table name | drop table if exists indicate | Oracle There is no exists keyword , If you want to achieve the same effect, you can judge whether there is one |
| Add columns | alter table emp add name varchar2(10);alter table emp add(name varchar2(10),password varchar2(30)) | alter table emp add column name varchar(10);alter table emp add column name varchar(10),add column password varchar(30) | MySQL Adding fields requires add column+ The field name and type you want to add , If you want to add multiple fields, you need add column.Oracle Adding fields does not require column, When adding multiple fields, you only need to put them in the same bracket |
| Delete column | ditto , hold add Instead of drop | ditto , hold add Instead of drop | ditto , Replace the addition with deletion ,add Instead of drop |
| Change column names | alter table emp rename column name to username | alter table emp change column name username varchar(10) | MySQL adopt change column Original field Field to be changed The character type must be added .Oracle adopt rename column Original field to New fields Cannot have field type , Field type requires alter table Table name modify ( Field data type constraint condition ) |
| Modify column type | alter table emp modify (name varchar2(30)) | alter table emp modify column name varchar(30) | Oracle It cannot be modified when there is data listed, and it can be modified when there is no .MySQL It can be modified at any time , But when there is data, it may cause data loss , You can add temporary columns , After importing the data into the temporary column, delete the original column , And change the temporary column name to the original column name |
| Indexes | Creating an index makes little difference , When deleting an index, you can directly drop index indexName, Query index queries through views | To delete an index, you need to specify a table name ,drop index indexName on tableName,alter table tableName drop index indexName, direct show index from tableName You can find the index | MySQL Indexes can have duplicate names, so you need to specify the table name when deleting , So the index is table level ,Oracle The index in cannot have the same name , It is database level |
| An empty string | ‘’ Namely null | '' and null There is a difference | Oracle in ’‘ and null There is no difference , But in MySQL in ’‘ Is for empty characters ,null There is nothing ’ vacuum ’, Try not to insert ’’ |
| Partition table | It can realize automatic partition | No automatic partition | MySQL To realize automatic partitioning, you need to implement stored procedures |
Four 、 Permission differences
| Category | Oracle | MySQL | difference |
|---|---|---|---|
| Create user | stay create user You need to determine permissions when | direct create user user_name identified by user_password | Oracle Only two... Are needed connect,resource Permission to users , The user can operate the data , But it can't cross users .Mysql You need to give permissions separately in , You can also give it all , Different users can share some tables ,Oracle You need to add the identity of another user when accessing |
| Delete user | drop user user_name cascade | drop user user_name | cascade Delete all |
| … | … | … | … |
5、 ... and 、 Function difference
| Category | Oracle | MySQL | difference |
|---|---|---|---|
| String function | insert(‘qwer’,‘asdf’,2) | insert(‘qwer’,‘asdf’) | Oracle You can specify the insertion position , from 2 Start inserting .MySQL Insert from the default location |
| substr(‘asdf’,2,2) | substring(‘asdf’,2,2) | Only the function name is different , Other usages are the same | |
| length() | char_length() | Oracle in select length(‘asdf’) value from dual.MySQL in select char_length(‘asdf’) value | |
| Control flow function | nvl(u.email_address,10) | ifnull(u.email_address,10) perhaps isnull(u.email_address) | Oracle If email It's empty 10 Replace ,MySQL If it is empty, it will not be replaced, but will be displayed as 10, If there is no number, it will be displayed as 1, If it is not empty, it will be displayed as 0 |
| … | … | … | … |
unfinished .
边栏推荐
猜你喜欢

多商户商城系统功能拆解08讲-平台端商品分类

【mycat】mycat介绍

Flink 生产环境配置建议

【mycat】mycat安装

【mycat】mycat相关概念

Similarities and differences of ODS, data mart and data warehouse

Multi merchant mall system function disassembly lecture 12 - platform side commodity evaluation

关于卷积神经网络中的“输入通道”和“输出通道”的概念

The repetition detection function of PHP multi line text content and count the number of repetitions

likeshop | 单商户商城系统代码开源无加密-PHP
随机推荐
达梦数据库_在使用过程中的需要注意的小事项
[vSphere high availability] working principle of host and virtual machine fault monitoring
Canal+kafka actual combat (monitor MySQL binlog to realize data synchronization)
Likeshop single merchant mall system is built, and the code is open source without encryption
【mycat】mycat搭建读写分离
Wechat applet returns parameters or trigger events
Brief introduction of [data mining] cluster analysis
达梦数据库_用户口令策略
Multi merchant mall system function disassembly lecture 12 - platform side commodity evaluation
【数据挖掘】聚类分析的简要介绍
How can the multiple-choice and single choice results of PHP be displayed in the foreground?
达梦数据库_逻辑备份
Multi merchant mall system function disassembly lecture 07 - platform side commodity management
多商户商城系统功能拆解07讲-平台端商品管理
Canal+kafka实战(监听mysql binlog实现数据同步)
Recommend a fully open source, feature rich, beautiful interface mall system
多商户商城系统功能拆解05讲-平台端商家主营类目
多商户商城系统功能拆解04讲-平台端商家入驻
Too many database connections
Public chain Sui layer1 network