PostgreSQL转换为Mysql

CSDN博客

由于postgresql和mysql的使用方式不同,所以不能直接导出sql转换为mysql所用的,所以

下面是我总结的几点

DROP TABLE IF EXISTS "public"."college";

CREATE TABLE "public"."college" (

"college_id" int4 DEFAULT nextval('college_college_id_seq'::regclass) NOT NULL,

"college_code" varchar(50) COLLATE "default" NOT NULL,

"college_name" varchar(100) COLLATE "default" NOT NULL,

"college_web_site" varchar(50) COLLATE "default",

"standby0" varchar(500) COLLATE "default",

"standby4" varchar(500) COLLATE "default",

"standby3" varchar(500) COLLATE "default",

"standby2" varchar(500) COLLATE "default",

"standby1" varchar(500) COLLATE "default"

)

WITH (OIDS=FALSE)

;

-- ----------------------------

-- Records of college

-- ----------------------------

INSERT INTO "public"."college" VALUES ('30', '10007', '北京理工大学', 'http://www.bit.edu.cn/', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('31', '10698', '西安交通大学', 'http://www.xjtudlc.com/', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('32', '11414', '中国石油大学(北京)', 'http://www.cupde.cn/cms/fxlsy/index.htm', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('33', '10699', '西北工业大学', 'http://www.nwpunec.net/', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('34', '11415', '中国地质大学(北京)', 'http://www.cugbonline.cn/info.do?columnId=249', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('35', '10718', '陕西师范大学', 'http://sde.snnu.edu.cn/', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('36', '', '北京大学', '', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('37', '10030', '北京外国语大学', 'http://www.beiwaionline.com/', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('38', '10008', '北京科技大学', 'http://cr.ustb.edu.cn/', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('39', '10055', '南开大学', 'http://weo.nankai.edu.cn', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('40', '10056', '天津大学', 'http://www.etju.com/', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('41', '10610', '四川大学', 'http://www.scude.cc/', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('42', '', '西南大学', '', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('43', '10614', '电子科技大学', 'http://www.remotedu.com/', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('44', '', '西南科技大学', '', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('45', '10613', '西南交通大学', 'http://www.xnjd.cn/Index_index.action', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('46', '10422', '山东大学', 'http://jxjw.sdns.wljy.sdu.edu.cn/mh', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('47', '10183', '吉林大学', 'http://dec.jlu.edu.cn/cms/webucation/index.htm', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('48', '', '郑州大学', '', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('49', '', '中南大学', '', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('50', '', '中国传媒大学', '', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('52', '', '四川农业大学', '', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('53', '', '国家开放大学', '', null, null, null, null, null);

INSERT INTO "public"."college" VALUES ('54', ' ', '北京大学医学网络教育学院', ' ', null, null, null, null, null);

-- ----------------------------

-- Alter Sequences Owned By

-- ----------------------------

-- ----------------------------

-- Indexes structure for table college

-- ----------------------------

CREATE INDEX "idx_college_college_name" ON "public"."college" USING btree ("college_name");

-- ----------------------------

-- Primary Key structure for table college

-- ----------------------------

ALTER TABLE "public"."college" ADD PRIMARY KEY ("college_id");

1,将输出的PostgreSql语句输出的表结构和文本内容放在word上边,然后在使用Notepad++打开或者直接打开word文本

  (1)将“public".  字段替换为空

  (2)删除 nextval() 函数信息

  (3)将COLLATE 替换为空

  (4)将“”字符替换为mysql识别的·字符(~号电脑Esc下面的字符)

  (5)将int4 替换为int(11)

  (6)将default替换为空

  (7)将创建表加上唯一  PRIMARY KEY (`表唯一ID`)

  (8)将with(oids = false)替换为 ENGINE=InnoDB  CHARSET=utf8;

这样,执行mysql语句就可以创建表了,然后在插入数据,你就可以为所欲为了!!!

同样,如何你想Mysql转换为PostgreSQL,逆向思维就可以了!!!

本文由 黑白世界4648 第一时间收藏到GET,原文来自 → blog.csdn.net

「GetParty」

关注微信号,推送好文章

微信中长按图片即可关注

更多精选文章

评论
微博一键登入