SQL DDL从MySQL到Oracle

最新一个项目的sql ddl为MySQL准备的,我想在Oracle中使用。之前不太了解两者的区别,结果报错一坨。于是顶着头皮开始看什么问题,以下是我陷过的坑,让大家看看。废话少说,上代码:
create table cms_ad (
f_ad_id int not null,
f_site_id int not nul
f_adslot_id int not null,
f_name varchar(150) not null comment '名称',
f_begin_date datetime comment '开始时间',
f_end_date datetime comment '结束时间',
f_url varchar(255) comment '广告url',
f_text varchar(255) comment '文字',
f_script mediumtext comment '代码',
f_image varchar(255) comment '图片',
f_flash varchar(255) comment 'flash',
f_seq int not null default 1 comment '排序',
primary key (f_ad_id)
) engine = innodb;
alter table cms_ad comment '广告表';

  • Oracle是不存在engine的,所以engine=xxx是要去掉的。
     
  • Oracle的comment是这么用的:comment on column xxx is xxx 、comment on table xxx is xxx

  • Oracle和MySQL在数据类型方面有很多差异,比如Oracle不存在mediumtext 这个数据类型。更多这方面的差异推荐这位大神的博客http://blog.csdn.net/yzsind/article/details/7948226

以上是我目前发现的差异,最后在附上我如何利用sed命令批量消除这些差异的的命令

  • sed 's/^alter table \(.*\) comment \(.*\)\;/comment on table \1 is \2\;/' mysql.sql > oracle.sql
     
    。其效果是将mysql.sql中的alter table cms_ad comment '广告表';变成oracle.sql中的comment on table cms_ad is '广告表';
     
    其他的待继续更新吧。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值