SQL Migration Generator

Generate ALTER / CREATE migration scripts

SQL Migration Generator is a free online Developer tool. Generate ALTER / CREATE migration scripts Related terms: 迁移 · migration · ALTER TABLE · 建表 · DDL · 版本管理. Use it on this page without signing in.

列名类型NULL默认值主键
生成的 SQL 脚本
正向迁移
CREATE TABLE users (
  id BIGINT NOT NULL,
  username VARCHAR(64) NOT NULL,
  email VARCHAR(255) NOT NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
);
回滚脚本
DROP TABLE IF EXISTS users;

生成标准 SQL DDL,兼容 MySQL / PostgreSQL。生产环境执行前请先在测试库验证,大表 ALTER 请关注锁表风险,必要时使用 pt-online-schema-change 等在线变更工具。

Help

使用说明

  1. 选择操作类型:建表 / 加列 / 改列 / 删列 / 加索引 / 改默认值
  2. 填写表名、列名、数据类型等参数
  3. 自动生成标准 SQL DDL 语句
  4. 可选生成回滚脚本

常见问题

  • 支持哪些数据库? 生成标准 SQL,兼容 MySQL/PostgreSQL
  • 大表 ALTER 会有锁吗? MySQL 8.0+ 大部分 ALTER 已支持在线 DDL
  • 能生成回滚吗? 勾选「包含回滚脚本」自动生成 DROP/ROLLBACK 语句

More Developer

View all

FAQ about SQL Migration Generator

What can SQL Migration Generator do?

SQL Migration Generator is a Developer tool. Generate ALTER / CREATE migration scripts You can finish the job on this page.

Who should use SQL Migration Generator?

Anyone handling 迁移 · migration · ALTER TABLE · 建表 · DDL · 版本管理 who does not want to install desktop software can use SQL Migration Generator in the browser.

Is SQL Migration Generator safe? Is my data uploaded?

This tool runs in your browser. We do not collect the content you enter into SQL Migration Generator just because you used it.

What similar tools exist?

Related tools in the same Developer group are listed at the bottom of this page.