44 Star 83 Fork 36

alchemystar / Lancer

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

Lancer

同步两个DB之间的schema,配置如下:
sourceHost=127.0.0.1:3306
sourceUser=root
sourcePass=123123123
sourceSchema=temp_db
sourceCharset=utf8

targetHost=127.0.0.1:3306
targetUser=root
targetPass=123123123
targetSchema=temp_test
targetCharset=utf8

autoExecute=YES //此处表明自动同步

原理: 通过捞取information_schema来比较source_schema和target_schema(可在不同实例)的表结构是否一致,
如果target_schema没有则这张表则创建,
如果target_schema表里面没有这个字段则alter add(保证顺序),
如果表里面有这个字段、但属性不一样则alter change,
另外还同步索引的元数据.
可以指定进行自动执行,也可以指定打印出对应的执行语句,语句如下所例:
alter table mystique_test.t_test_3 change id id bigint(20) NOT NULL AUTO_INCREMENT COMMENT ''
alter table mystique_test.t_test_3 add index (name)
alter table mystique_test.t_test_3 drop index name_id
alter table mystique_test.t_test_3 add id_2 varchar(50) NULL DEFAULT '' COMMENT '' after name

Repository Comments ( 7 )

Sign in to post a comment

About

MySql之自动同步表结构 能够自动比较RD环境和QA不同的数据库的表结构,并生成对应的alter语句,且自动执行。分析地址: https://my.oschina.net/alchemystar/blog/858996 expand collapse
Java
Cancel

Releases

No release

Lancer

Contributors

All

Activities

Load More
can not load any more
Java
1
https://gitee.com/alchemystar/Lancer.git
git@gitee.com:alchemystar/Lancer.git
alchemystar
Lancer
Lancer
master

Search