MySQL和Oracle开发差异
1) 数据类型差异
|
Oracle |
MySQL |
注释 |
|
单独创建序列来实现 |
自动增长的数据类型 |
|
|
varchar2 |
varchar |
|
|
number |
tinyint,smallint,mediumint,int,bigint float,double |
|
|
clob |
text,mediumtext,longtext |
|
|
date |
datetime |
|
|
无 |
enum |
|
|
raw |
binary(n),varbinary(n) |
|
|
无 |
bit(n) |
|
|
blob |
blob,mediumblob,longblob |
2) 内建函数差异
|
Oracle |
MySQL |
注释 |
|
length |
char_length |
|
|
substr |
substring |
|
|
nvl |
ifnull |
|
|
decode |
case |
|
|
to_char |
date_format,time_format |
|
|
to_date |
str_to_date |
|
|
trunc |
cast |
|
|
to_number |
cast |
|
|
date+/-n |
date_add |
|
|
date1-date2 |
datediff |
3) SQL语句差异
|
操作 |
Oracle |
MySQL |
|
创表指定表空间 |
create table…tablespace x |
没有表空间,使用默认存储引擎 |
|
CTAS建表 |
create table…as select…不能新增字段和改变字段属性 |
create table t1(a int,b int) as select a,b,a,b from t2可以选择新的字段和字段属性 |
|
表结构复制 |
create table t1 as select * from t2 where 1=0,只复制字段定义,不包括约束 |
create table t1 like t2,复制包括约束 |
|
全局分区索引 |
create index…global partition by |
无 |
|
重命名列 |
alter table t1 rename c1 to c2 |
alter table t1 change c1 c2 |
|
修改列类型 |
alter table t1 modify c1 integer |
alter table t1 change c1 c1 int |
|
修改列缺省值 |
alter table t1 modify c1 default 0 |
alter table t1 change c1 c1 int default 0 |
|
修改列非空 |
alter table t1 modify c1 not null |
alter table t1 change c1 c1 int not null |
|
重命名表 |
rename t1 to t2 |
alter table t1 rename t2 rename table t1 to t2 |
|
删除索引 |
drop index idx1 |
alter table t1 drop index idx1 drop index idx1 on t1 |
|
重命名索引 |
alter index idx1 rename to idx2 |
删除重建 |
|
重建索引 |
alter index idx1 rebuild |
无 |
|
禁用索引 |
alter index idx1 unusable |
无 |
|
删除表 |
drop table t1,如果表不存在报错 |
drop table if exists t1,判断表是否存在,存在删除,不存在不报错 |
|
重命名视图 |
rename v1 to v2 |
rename view v1 to v2 |
|
左右连接 |
select * from t1,t2 where t1.c1=t2.c2(+); select * from t1,t2 where t1.c1(+)=t2.c2; |
select * from t1 left join t2 on t1.c1=t2.c2; select * from t1 right join t2 on t1.c1=t2.c2; |
|
交集 |
select intersect select |
select inner join select;使用inner join代替 |
|
差集 |
Select minus select |
select left join where,使用left join where代替 |
|
获取固定值 |
select 1 from dual |
select 1 |
|
字段连接 |
select c1||c2 from t1 |
select concant(c1,c2) from t1 |
|
结果子查询 |
select * from (select * from t) |
select * from (select * from t) t1 结果集需要有别名 |
|
Merge |
merge into |
replace into |
|
行号 |
rownum |
无,需要使用用户变量来实现 |
|
分析函数 |
max() over() min() over() …… |
无,需要自行实现 |
|
位图索引 |
create bitmap index |
无 |
|
Top查询 |
select * from (select rownum from t1 order by c1) where rownum>=1 and rownum<=5 |
select * from t1 order by c1 limit 5 |
|
语句内部临时表 |
with as |
无 |
|
创建存储过程/ |
create or replace procedure |
create procecure |
|
创建函数 |
create or replace function |
create function |
|
创建视图 |
create or replace view |
create view |
|
创建触发器 |
create or replace trigger |
create trigger |
|
创建包 |
create or replace package |
无 |
|
创建用户 |
create user u1 identified by p1 default tablespace x temporary tablespace y |
create user u1 identified by p1 |
|
修改密码 |
alter user u1 identified by p2 |
mysqladmin -u u1 -p p1 password p2 |
|
大小写 |
不区分 |
缺省数据库、表名区分大小写,列名不区分; 可以设置lower_case_table_names=1都不分区 |
3) 子程序差异
Oracle中创建的匿名PL/SQL块、PL/SQL函数和存储过程,MySQL需要全部重新实现
MySQL和Oracle开发差异的更多相关文章
- mybatis中mysql和oracle的差异
1.applicationContext.xml中的配置差异: 在applicationContext.xml的数据源dataSource的配置中,mysql数据库需要心跳包的配置,而oracle中不 ...
- SQLServer、MySQL、Oracle语法差异小集锦
一.差异集锦 在建表的时候,只有自增的语法不同. 下面给出3种数据库通用的建表与初始化测试语句: CREATE TABLE Country( Id int PRIMARY KEY, Name ) ); ...
- MySQL,Oracle,PostgreSQL通过web方式管理维护, 提高开发及运维效率
在开发及项目运维中,对数据库的操作大家目前都是使用客户端工具进行操作,例如MySQL的客户端工具navicat,Oracle的客户端工具 PL/SQL Developer, MSSQL的客户端工具查询 ...
- 开发中mysql和oracle的区别
首先就不描述mysql与oracle在整个数据库系统上的区别了,仅从程序员开发的角度来说: 1.主键: mysql一般会用到一个自增的属性,例如设置一个id字段,类型设置为auto increment ...
- MySQL,Oracle,PostgreSQL,mongoDB 通过web方式管理维护, 提高开发及运维效率
在开发及项目运维中,对数据库的操作大家目前都是使用客户端工具进行操作,例如MySQL的客户端工具navicat,Oracle的客户端工具 PL/SQL Developer, MSSQL的客户端工具查询 ...
- 谈谈 mysql和oracle的使用感受 -- 差异
之前一直使用mysql作为存储数据库,虽然中间偶尔使用sqlite作为本地数据库存储,但没有感觉多少差别. 后来遇上了oracle,且以其作为主要存储,这下就不得不好好了解其东西了.oracle作为商 ...
- MySQL与Oracle 差异比较之四条件循环语句
循环语句 编号 类别 ORACLE MYSQL 注释 1 IF语句使用不同 IF iv_weekly_day = 'MON' THEN ii_weekly_day := 'MON';ELS ...
- 【无私分享:ASP.NET CORE 项目实战(第十二章)】添加对SqlServer、MySql、Oracle的支持
目录索引 [无私分享:ASP.NET CORE 项目实战]目录索引 简介 增加对多数据库的支持,并不是意味着同时对多种数据库操作,当然,后面,我们会尝试同时对多种数据库操作,这可能需要多个上下文,暂且 ...
- qlserver、Mysql、Oracle三种数据库的优缺点总结
这篇文章主要介绍了sqlserver.Mysql.Oracle三种数据库的优缺点总结,需要的朋友可以参考下 一.sqlserver优点:易用性.适合分布式组织的可伸缩性.用于决策支持的数据仓库功能 ...
随机推荐
- 开源中国IOSclient
我想看看别人开发项目.通过吸收经验,然后找到开放的中国,丹尼尔一些网上也开发了自己的开源在中国client 在网上看到很多网友说,不能下载东西像安装,我带来了我的方式,其中的一些朋友想帮忙. http ...
- ThinkPhp学习02
原文:ThinkPhp学习02 一.什么是MVC M -Model 编写model类 对数据进行操作 V -View 编写html文件,页面呈现 C -Controll ...
- [每日一题] 11gOCP 1z0-052 :2013-09-5 runInstaller oracle of no swap
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/11186995 正确答案:A 我们先来看下面这张截图,这是我在安装Oracle 11.2.0 ...
- POJ 2991 Crane(线段树+计算几何)
POJ 2991 Crane 题目链接 题意:给定一个垂直的挖掘机臂.有n段,如今每次操作能够旋转一个位置,把[s, s + 1]专程a度,每次旋转后要输出第n个位置的坐标 思路:线段树.把每一段当成 ...
- win7+vs2008+opencv
1.下载安装VS2008,然后直接下载opencv的windows的安装版, 2.把opencv解压出来,我的路径为:D:\Program\opencv 3.配置PATH:电脑--属性--高级系统设置 ...
- 从零开始学C++之从C到C++(二):引用、内联函数inline、四种类型转换运算符
一.引用 (1).引用是给一个变量起别名 定义引用的一般格式:类型 &引用名 = 变量名: 例如:int a=1; int &b=a;// b是a的别名,因此a和b是同一个单元 注 ...
- 慕尼黑大学公开课 Competitive Strategy(竞争策略)总结
第一章博弈 同时的博弈:双方同时定制策略 如果有显著的次优策略总是不如另一个,则剔除它. 如果一个策略组合中没有一方可以单独改变其策略以提高回报,则称为Nash均衡.一个游戏可能没有也可能有多个Nas ...
- Java Swing界面编程(31)---菜单条:JMenu
package com.beyole.test; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMe ...
- 具体解释java定时任务
在我们编程过程中假设须要运行一些简单的定时任务,无须做复杂的控制.我们能够考虑使用JDK中的Timer定时任务来实现. 以下LZ就其原理.实例以及Timer缺陷三个方面来解析java Timer定时器 ...
- xcode target
A target specifies a product to build and contains the instructions for building the product from a ...