oracle to mysql

前端之家收集整理的这篇文章主要介绍了oracle to mysql前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

oracle的序列变成MysqL的 : MysqL 创建一个表 并创建一个函数即可

oracle:

-- Create sequence
create sequence CHATACTIVITY_SEQ
minvalue 1
maxvalue 9999999999999999999999999999
start with 52373
increment by 1
cache 20;



MysqL

DROP TABLE IF EXISTS `chatactivity_seq`;
CREATE TABLE `chatactivity_seq` (
`stub` char(1) DEFAULT NULL,
`id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `stub` (`stub`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


-- ----------------------------
-- Records of chatactivity_seq
-- ----------------------------
INSERT INTO `chatactivity_seq` VALUES ('a','1');



。。。。。。。。。。。。。建函数

CREATE FUNCTION chatactivity_seq() RETURNS bigint(20) BEGIN REPLACE INTO chatactivity_seq(stub) VALUES ('a'); RETURN (SELECT LAST_INSERT_ID() from dual); END;

猜你在找的Oracle相关文章