将 SQL Server 转换为 MySQL
拖入 SSMS 的"生成脚本"写出的包含架构和数据的脚本(.sql 或 .sql.gz,UTF-16 或 UTF-8),即可下载包含相同表、键、索引和数据的 MySQL 脚本。MySQL 无法原样存储的每个值,以及它不支持的每个对象,都会在报告中列出。
已转换 18 行,3 处修正,无拒绝
shop_2024_sqlserver.sql 中的表SQL Server 转储 · 由 SQL Server Management Objects 写出 · utf-8
orders10 行1
11 列 id int not null customer_id int not null status varchar(10) not null total decimal(19,4) not null items tinyint unsigned not null ordered_at datetime not null shipped_at datetime(6) note text details text order_ref char(36) not null total_with_tax decimal(12,2) customers8 行2
8 列 id int not null name varchar(100) not null email varchar(200) not null country char(2) not null is_active tinyint(1) not null signed_up date created_at datetime not null row_version blob
未转换
- 视图 paid_orders
- 触发器 orders_no_negative
每种数据库都用自己的语言编写这些对象。请为 MySQL 重写它们。
-- Written by IntoSQL from a SQL Server dump. Load it with: mysql --default-character-set=utf8mb4 <database> < <file>
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
SET UNIQUE_CHECKS = 0;
SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO,ALLOW_INVALID_DATES';
CREATE TABLE `orders` (
`id` int NOT NULL AUTO_INCREMENT,
`customer_id` int NOT NULL,
`status` varchar(10) NOT NULL DEFAULT 'pending',
`total` decimal(19,4) NOT NULL,
`items` tinyint unsigned NOT NULL DEFAULT 1,
`ordered_at` datetime NOT NULL,
`shipped_at` datetime(6),
`note` text,
`details` text,
`order_ref` char(36) NOT NULL,
`total_with_tax` decimal(12,2) GENERATED ALWAYS AS (cast(`total` * (1.16) AS DECIMAL(12,2))) STORED,
PRIMARY KEY (`id`),
KEY `idx_orders_customer` (`customer_id`),
KEY `idx_orders_status_date` (`status`,`ordered_at`),
CONSTRAINT `check2` CHECK (`status` = 'cancelled' OR `status` = 'shipped' OR `status` = 'paid' OR `status` = 'pending'),
CONSTRAINT `check3` CHECK (`total` >= (0)),
FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`)
) AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `customers` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`email` varchar(200) NOT NULL,
`country` char(2) NOT NULL DEFAULT 'US',
`is_active` tinyint(1) NOT NULL DEFAULT 1,
`signed_up` date,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`row_version` blob,
PRIMARY KEY (`id`),
UNIQUE KEY (`email`)
) AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='People who bought at least once';
INSERT INTO `customers` (`id`,`name`,`email`,`country`,`is_active`,`signed_up`,`created_at`) VALUES (1,'Ana Martínez','ana@example.com','MX',1,'2023-01-15','2023-01-15 10:24:00.000000');
INSERT INTO `customers` (`id`,`name`,`email`,`country`,`is_active`,`signed_up`,`created_at`) VALUES (2,'Zoë Müller','zoe@example.de','DE',1,'2023-02-03','2023-02-03 08:11:42.000000');
INSERT INTO `customers` (`id`,`name`,`email`,`country`,`is_active`,`signed_up`,`created_at`) VALUES (3,'José Peña','jose@example.es','ES',0,'2023-03-21','2023-03-21 19:05:17.000000');
INSERT INTO `customers` (`id`,`name`,`email`,`country`,`is_active`,`signed_up`,`created_at`) VALUES (4,'李雷','lilei@example.cn','CN',1,'2023-05-09','2023-05-09 02:40:00.000000');
INSERT INTO `customers` (`id`,`name`,`email`,`country`,`is_active`,`signed_up`,`created_at`) VALUES (5,'Noah O\'Brien','noah@example.ie','IE',1,NULL,'2023-06-30 14:00:00.000000');
INSERT INTO `customers` (`id`,`name`,`email`,`country`,`is_active`,`signed_up`,`created_at`) VALUES (6,'Amélie Laurent','amelie@example.fr','FR',1,'2024-01-02','2024-01-02 09:30:00.000000');
INSERT INTO `customers` (`id`,`name`,`email`,`country`,`is_active`,`signed_up`,`created_at`) VALUES (7,'Ravi Patel','ravi@example.in','IN',0,'2024-02-29','2024-02-29 23:59:59.000000');
INSERT INTO `customers` (`id`,`name`,`email`,`country`,`is_active`,`signed_up`,`created_at`) VALUES (8,'Sofia Rossi 🌻','sofia@example.it','IT',1,'2024-04-12','2024-04-12 12:12:12.000000');
INSERT INTO `orders` (`id`,`customer_id`,`status`,`total`,`items`,`ordered_at`,`shipped_at`,`note`,`details`,`order_ref`) VALUES (1,1,'shipped',129.9000,3,'2024-03-01T10:00:00.000000','2024-03-02T16:30:00.123456',NULL,'{"gift": false}','0b7a4c2e-3f1d-4e8a-9c55-1a2b3c4d5e6f');
INSERT INTO `orders` (`id`,`customer_id`,`status`,`total`,`items`,`ordered_at`,`shipped_at`,`note`,`details`,`order_ref`) VALUES (2,2,'paid',54.0000,1,'2024-03-02T11:15:00.000000',NULL,'Gift wrap 🎁','{"gift": true, "wrap": "red"}','1c8b5d3f-4a2e-4f9b-8d66-2b3c4d5e6f70');
INSERT INTO `orders` (`id`,`customer_id`,`status`,`total`,`items`,`ordered_at`,`shipped_at`,`note`,`details`,`order_ref`) VALUES (3,1,'cancelled',12.5000,1,'2024-03-03T09:45:00.000000',NULL,'Customer changed their mind',NULL,'2d9c6e4a-5b3f-4a0c-9e77-3c4d5e6f7081');
INSERT INTO `orders` (`id`,`customer_id`,`status`,`total`,`items`,`ordered_at`,`shipped_at`,`note`,`details`,`order_ref`) VALUES (4,4,'shipped',980.0000,12,'2024-03-05T02:10:00.000000','2024-03-07T08:00:00.000000','请小心轻放','{"fragile": true}','3e0d7f5b-6c4a-4b1d-8f88-4d5e6f708192');
INSERT INTO `orders` (`id`,`customer_id`,`status`,`total`,`items`,`ordered_at`,`shipped_at`,`note`,`details`,`order_ref`) VALUES (5,5,'pending',45.7500,2,'2024-03-08T17:20:00.000000',NULL,'Leave at the door; ring twice',NULL,'4f1e806c-7d5b-4c2e-9a99-5e6f708192a3');
INSERT INTO `orders` (`id`,`customer_id`,`status`,`total`,`items`,`ordered_at`,`shipped_at`,`note`,`details`,`order_ref`) VALUES (6,6,'shipped',310.4000,5,'2024-03-10T13:00:00.000000','2024-03-11T09:00:00.000000','Fragile: "glass"','{"fragile": true}','50f2917d-8e6c-4d3f-8baa-6f708192a3b4');
INSERT INTO `orders` (`id`,`customer_id`,`status`,`total`,`items`,`ordered_at`,`shipped_at`,`note`,`details`,`order_ref`) VALUES (7,8,'paid',76.2000,2,'2024-03-11T18:45:00.000000',NULL,NULL,NULL,'6103a28e-9f7d-4e40-9cbb-708192a3b4c5');
INSERT INTO `orders` (`id`,`customer_id`,`status`,`total`,`items`,`ordered_at`,`shipped_at`,`note`,`details`,`order_ref`) VALUES (8,2,'shipped',19.9900,1,'2024-03-12T08:00:00.000000','9999-12-31T23:59:59.999999','Shipped date set to the maximum by an old import',NULL,'7214b39f-a08e-4f51-8dcc-8192a3b4c5d6');
INSERT INTO `orders` (`id`,`customer_id`,`status`,`total`,`items`,`ordered_at`,`shipped_at`,`note`,`details`,`order_ref`) VALUES (9,3,'shipped',64.0000,2,'2024-03-14T15:30:00.000000','2024-03-15T10:00:00.000000','Two parcels','{"parcels": [1, 2]}','8325c4a0-b19f-4062-9edd-92a3b4c5d6e7');
INSERT INTO `orders` (`id`,`customer_id`,`status`,`total`,`items`,`ordered_at`,`shipped_at`,`note`,`details`,`order_ref`) VALUES (10,7,'paid',1499.0000,1,'2024-03-15T21:05:00.000000',NULL,'C:\\Users\\ravi\\invoice.pdf',NULL,'9436d5b1-c2a0-4173-8fee-a3b4c5d6e7f8');
SET UNIQUE_CHECKS = 1;
SET FOREIGN_KEY_CHECKS = 1;
修正
- orders 的 "shipped_at" 为 datetime2(7),其秒的位数多于 MySQL 能保留的位数,因此改为 datetime(6),并截断最后几位。
- customers 的 "created_at" 包含带时区的时间点;MySQL 没有能保留时区的类型,因此以 UTC 存储为 datetime。
- customers 的 "row_version" 是 SQL Server 自动设置的行版本;转储中没有它的值,因此改为 blob,并保持为空。
需要检查
- 源数据中有 6 个文本列比较时不区分大小写;MySQL 精确比较,因此唯一键和搜索的行为可能不同。 在需要的列上使用不区分大小写的排序规则或列类型。
- 2 个视图、触发器、例程或事件未转换;报告逐一列出了它们。 请在 MySQL 中手动重新创建它们。
- orders 上的检查约束 check1 无法为 MySQL 写出(function isjson),因此未创建。 如果它重要,请手动编写该检查约束。
- orders 上的索引 idx_orders_pending 使用了无法为 MySQL 写出的表达式(neither MySQL 5.7 nor MariaDB index an expression),因此未创建。 如果查询需要,请手动创建该索引。
- orders 中 "order_ref" 的默认值无法为 MySQL 写出(a default expression needs MySQL 8.0.13),因此该列没有默认值。 如果新行需要,请手动添加默认值。
文件在这台电脑上转换,永远不会上传。
其他示例:
从 SQL Server 到 MySQL 的变化
每一行是转换器应用的一条规则,以及该规则更改你的数据时在报告中写入的记录。
bit
tinyint(1)
MySQL 的 BOOLEAN 就是 TINYINT(1):1 和 0,与 bit 存储的一样。
char(n), varchar(n), nchar(n), nvarchar(n), varchar(max), text
char(n),不超过 1024 个字符时为 varchar(n),更长则为 text 类型
文本以 utf8mb4 保留每个字符。键中的列最多为 varchar(768),这是键能容纳的最大长度;带默认值的文本也是如此,因为 MySQL 5.7 只允许 varchar 有默认值。
decimal(p,s), money, smallmoney
decimal(p,s);money 为 decimal(19,4)
decimal 可容纳 65 位数字,多于 SQL Server 的 38 位,因此每个值都是精确的。
datetime, datetime2, smalldatetime
datetime(p)
在两者中,datetime 都是挂钟读数。
datetime2(7), time(7) and datetimeoffset(7)
秒保留六位小数,第七位截断
MySQL 保留到微秒;第七位(100 纳秒)直接截断,从不四舍五入,因此没有值会进到下一秒或下一天。
报告记录: fraction_cut
datetimeoffset
UTC 的 datetime(p)
MySQL 的 TIMESTAMP 只到 2038 年,因此时间点以 UTC 存储为 datetime;无论每个值原有的偏移量是多少,都是同一时刻。
报告记录: moments_as_utc
time
time(p)
一天中的时刻相同。
dates before the year 1000
NULL
MySQL 存储 1000 到 9999 年,而 SQL Server 可追溯到公元 1 年。这些值变为 NULL,报告会统计其数量。
报告记录: date_out_of_range
json (SQL Server 2025)
json
JSON 值相同,MySQL 的 JSON 函数可以读取。
uniqueidentifier
char(36)
标识符相同,以小写写出。
binary, varbinary, image
binary(n)、varbinary(n) 和 blob 类型
字节仍然是字节。
geometry, geography
blob,存放 SQL Server 自己的字节
SSMS 以 SQL Server 的序列化格式写出空间值,这些字节会逐字节保留。
报告记录: spatial_as_native
rowversion, timestamp
blob,空
行版本由 SQL Server 自动设置,SSMS 不会为其写出值。
报告记录: rowversion_empty
xml, sql_variant, hierarchyid, vector
longtext
MySQL 没有对应的类型;xml 和 sql_variant 保留每个值的文本,hierarchyid 保留其路径,例如 /1/2/。
报告记录: type_replaced
collations that ignore case (_CI_)
精确比较(utf8mb4_bin)
表使用 utf8mb4_bin,因此唯一键能区分 SQL Server 区分的值;不区分大小写的列会失去这一点。重音规则因版本而异,因此没有任何 _ci 排序规则能在每个版本上与 SQL Server 的一致。
报告记录: case_insensitive_collation
IDENTITY
AUTO_INCREMENT,从最大的 id 之后继续
由主键的第一列计数;计数器从最大的 id 之后继续。
IDENTITY columns that don't lead the primary key
普通整数
MySQL 每个表只为一列计数,且该列位于键的开头;其他列保留其值,不带计数器。
报告记录: counter_dropped
CREATE SEQUENCE
不创建
MySQL 没有序列。序列分配过的值都在行中。
报告记录: sequence_not_converted
computed columns
生成列,PERSISTED 时为 STORED,否则为 VIRTUAL
MySQL 以相同的两种方式计算它们,CONCAT 的写法让 NULL 像在 SQL Server 中一样视为空。
computed columns with functions MySQL lacks
普通列
无法写出的公式会留下一个普通列和一条报告记录;SSMS 不会为计算列写出值。
报告记录: generated_not_translated
defaults with functions MySQL lacks, and NEXT VALUE FOR
无默认值
无法写出的默认值会被省略,并在报告中列出。
报告记录: default_not_translated
CHECK constraints
已转换
MySQL 5.7 保留它们但不检查;其他版本在导入每一行时检查。
CHECK constraints with functions MySQL lacks
不创建
无法写出的检查约束会被省略,并在报告中列出。
报告记录: check_skipped
CHECK constraints added WITH NOCHECK or disabled
不创建
SQL Server 不执行这些检查约束,因此行可能违反它们。
报告记录: check_not_enforced
filtered and columnstore indexes
不创建
IntoSQL 在整列上写出 b-tree 索引;其他索引请在导入后重新创建。
报告记录: index_skipped
foreign keys
外键,以 FOREIGN_KEY_CHECKS=0 导入
行可以按任意顺序导入,之后外键会检查新行。
foreign keys to tables the dump doesn't create
不创建
外键无法引用不存在的表。
报告记录: foreign_key_skipped
tables on a partition scheme
单个表,包含每个分区的行
行保持不变;如有需要,请在 MySQL 中重新对该表分区。
报告记录: partitions_dropped
temporal tables (SYSTEM_VERSIONING)
两个表:当前行和历史记录
表及其历史表作为普通表复制;MySQL 不会自动保留历史记录。
报告记录: system_versioning_dropped
schemas
单个数据库,每个表名前加上其 schema 名
MySQL 的 schema 就是数据库,而导入到单个数据库的脚本无法创建数据库;dbo 中的表保留原名。
报告记录: schemas_merged
NOT NULL columns with values that become NULL
去除 NOT NULL
值必须变为 NULL 的列无法保留 NOT NULL,否则导入会中止。
报告记录: not_null_relaxed
views, functions, procedures, triggers, synonyms, types and partition functions
在报告中列出
它们的代码用 T-SQL 编写,因此会列出来,由你重新创建。
报告记录: not_converted_objects
scripts without CREATE TABLE (data only)
根据值推断类型
只含数据的脚本只有行,因此类型来自值。
报告记录: no_schema
expressions in INSERT values
NULL
不运行数据库的转换器无法对它们求值。
报告记录: expression_value
types IntoSQL doesn't know
longtext
文本可以容纳任何值;请在导入后更改类型。
报告记录: unknown_type
NUL characters in text
保留
值按原样复制,NUL 字符会被转义。
text that isn't valid in its encoding
错误的字节变为替换字符
脚本是 UTF-8,每个值都必须是有效文本。
报告记录: invalid_utf8_replaced
text decoded twice (ñ)
按原样复制
脚本中存储的正是这些字符,因此按原样复制;报告会指出它们。
报告记录: mojibake_suspected
| 在 SQL Server 中 | 在 MySQL 中 | 报告记录 |
|---|---|---|
| bit | tinyint(1)MySQL 的 BOOLEAN 就是 TINYINT(1):1 和 0,与 bit 存储的一样。 | |
| char(n), varchar(n), nchar(n), nvarchar(n), varchar(max), text | char(n),不超过 1024 个字符时为 varchar(n),更长则为 text 类型文本以 utf8mb4 保留每个字符。键中的列最多为 varchar(768),这是键能容纳的最大长度;带默认值的文本也是如此,因为 MySQL 5.7 只允许 varchar 有默认值。 | |
| decimal(p,s), money, smallmoney | decimal(p,s);money 为 decimal(19,4)decimal 可容纳 65 位数字,多于 SQL Server 的 38 位,因此每个值都是精确的。 | |
| datetime, datetime2, smalldatetime | datetime(p)在两者中,datetime 都是挂钟读数。 | |
| datetime2(7), time(7) and datetimeoffset(7) | 秒保留六位小数,第七位截断MySQL 保留到微秒;第七位(100 纳秒)直接截断,从不四舍五入,因此没有值会进到下一秒或下一天。 | fraction_cut |
| datetimeoffset | UTC 的 datetime(p)MySQL 的 TIMESTAMP 只到 2038 年,因此时间点以 UTC 存储为 datetime;无论每个值原有的偏移量是多少,都是同一时刻。 | moments_as_utc |
| time | time(p)一天中的时刻相同。 | |
| dates before the year 1000 | NULLMySQL 存储 1000 到 9999 年,而 SQL Server 可追溯到公元 1 年。这些值变为 NULL,报告会统计其数量。 | date_out_of_range |
| json (SQL Server 2025) | jsonJSON 值相同,MySQL 的 JSON 函数可以读取。 | |
| uniqueidentifier | char(36)标识符相同,以小写写出。 | |
| binary, varbinary, image | binary(n)、varbinary(n) 和 blob 类型字节仍然是字节。 | |
| geometry, geography | blob,存放 SQL Server 自己的字节SSMS 以 SQL Server 的序列化格式写出空间值,这些字节会逐字节保留。 | spatial_as_native |
| rowversion, timestamp | blob,空行版本由 SQL Server 自动设置,SSMS 不会为其写出值。 | rowversion_empty |
| xml, sql_variant, hierarchyid, vector | longtextMySQL 没有对应的类型;xml 和 sql_variant 保留每个值的文本,hierarchyid 保留其路径,例如 /1/2/。 | type_replaced |
| collations that ignore case (_CI_) | 精确比较(utf8mb4_bin)表使用 utf8mb4_bin,因此唯一键能区分 SQL Server 区分的值;不区分大小写的列会失去这一点。重音规则因版本而异,因此没有任何 _ci 排序规则能在每个版本上与 SQL Server 的一致。 | case_insensitive_collation |
| IDENTITY | AUTO_INCREMENT,从最大的 id 之后继续由主键的第一列计数;计数器从最大的 id 之后继续。 | |
| IDENTITY columns that don't lead the primary key | 普通整数MySQL 每个表只为一列计数,且该列位于键的开头;其他列保留其值,不带计数器。 | counter_dropped |
| CREATE SEQUENCE | 不创建MySQL 没有序列。序列分配过的值都在行中。 | sequence_not_converted |
| computed columns | 生成列,PERSISTED 时为 STORED,否则为 VIRTUALMySQL 以相同的两种方式计算它们,CONCAT 的写法让 NULL 像在 SQL Server 中一样视为空。 | |
| computed columns with functions MySQL lacks | 普通列无法写出的公式会留下一个普通列和一条报告记录;SSMS 不会为计算列写出值。 | generated_not_translated |
| defaults with functions MySQL lacks, and NEXT VALUE FOR | 无默认值无法写出的默认值会被省略,并在报告中列出。 | default_not_translated |
| CHECK constraints | 已转换MySQL 5.7 保留它们但不检查;其他版本在导入每一行时检查。 | |
| CHECK constraints with functions MySQL lacks | 不创建无法写出的检查约束会被省略,并在报告中列出。 | check_skipped |
| CHECK constraints added WITH NOCHECK or disabled | 不创建SQL Server 不执行这些检查约束,因此行可能违反它们。 | check_not_enforced |
| filtered and columnstore indexes | 不创建IntoSQL 在整列上写出 b-tree 索引;其他索引请在导入后重新创建。 | index_skipped |
| foreign keys | 外键,以 FOREIGN_KEY_CHECKS=0 导入行可以按任意顺序导入,之后外键会检查新行。 | |
| foreign keys to tables the dump doesn't create | 不创建外键无法引用不存在的表。 | foreign_key_skipped |
| tables on a partition scheme | 单个表,包含每个分区的行行保持不变;如有需要,请在 MySQL 中重新对该表分区。 | partitions_dropped |
| temporal tables (SYSTEM_VERSIONING) | 两个表:当前行和历史记录表及其历史表作为普通表复制;MySQL 不会自动保留历史记录。 | system_versioning_dropped |
| schemas | 单个数据库,每个表名前加上其 schema 名MySQL 的 schema 就是数据库,而导入到单个数据库的脚本无法创建数据库;dbo 中的表保留原名。 | schemas_merged |
| NOT NULL columns with values that become NULL | 去除 NOT NULL值必须变为 NULL 的列无法保留 NOT NULL,否则导入会中止。 | not_null_relaxed |
| views, functions, procedures, triggers, synonyms, types and partition functions | 在报告中列出它们的代码用 T-SQL 编写,因此会列出来,由你重新创建。 | not_converted_objects |
| scripts without CREATE TABLE (data only) | 根据值推断类型只含数据的脚本只有行,因此类型来自值。 | no_schema |
| expressions in INSERT values | NULL不运行数据库的转换器无法对它们求值。 | expression_value |
| types IntoSQL doesn't know | longtext文本可以容纳任何值;请在导入后更改类型。 | unknown_type |
| NUL characters in text | 保留值按原样复制,NUL 字符会被转义。 | |
| text that isn't valid in its encoding | 错误的字节变为替换字符脚本是 UTF-8,每个值都必须是有效文本。 | invalid_utf8_replaced |
| text decoded twice (ñ) | 按原样复制脚本中存储的正是这些字符,因此按原样复制;报告会指出它们。 | mojibake_suspected |
将脚本导入 MySQL
脚本先创建表、复制行,再添加键、索引和外键,因此导入速度快,并会在遇到第一个错误时停止。
mysql --default-character-set=utf8mb4 mydb < sql_server.mysql.sql外键按转储中的声明创建,导入行时使用 FOREIGN_KEY_CHECKS=0,因此指向不存在的行的行不会中止导入。
对于较大的转储,请在服务器所在的机器上运行客户端;如果单行非常大,请调高 max_allowed_packet。
IntoSQL Pro 可以通过桌面应用或命令行将文件直接导入 MySQL,无需生成脚本。
如何转储 SQL Server 以获得最佳结果
转换器读取转储中的内容。以下选项能让转储保留更多数据:
- 在 SSMS 中右键单击数据库,依次选择"任务"、"生成脚本",然后选择表。dbatools、mssql-scripter 以及其他基于同一库的工具也会写出相同的脚本。
- 在"高级"中,将"要编写脚本的数据的类型"设为"架构和数据"。只含架构的脚本中,表没有行。
- 以 SSMS 默认的 Unicode 或 UTF-8 保存:两者的读取方式相同,也支持 gzip。
哪些内容不会转换
视图、函数、存储过程、触发器、同义词、规则和安全策略都是用 T-SQL 编写的。它们会按名称在报告中列出,绝不会被悄悄丢弃,以便你为 MySQL 重写。
关于 SQL Server 转 MySQL 的问题
这里没有你要的答案?请通过联系页面给我们留言,会有专人回复。 联系页面
我的转储会被上传吗?
不会。转换器在你的浏览器中运行,分块从磁盘读取转储,因此转储不会离开你的电脑。桌面应用和命令行也在你的电脑上转换。
转储可以多大?
转换器从不把整个转储放进内存:它按范围读取文件两次,边读边写出脚本。几 GB 的转储可以在浏览器、桌面应用和命令行中转换。
它能读取 SSMS 保存的 UTF-16 文件吗?
能。SSMS 默认以 UTF-16 保存脚本,而转换器同样能读取 UTF-16 和 UTF-8,无论是否经过 gzip 压缩,批处理之间的 GO 也能识别。
脚本可以来自哪些 SQL Server 版本?
由 SSMS、dbatools 或 mssql-scripter 从 SQL Server 2017 及更高版本写出的脚本。每个测试脚本都来自 SQL Server 2017、2022 和 2025,并与其源数据逐个单元格比较。
IDENTITY 值会保留吗?
会,每个表一列:作为主键第一列的 IDENTITY 列变为 AUTO_INCREMENT,从最大的 id 之后继续。由于 MySQL 没有序列,因此不创建序列,报告会说明这一点。
money、datetimeoffset 和其他 SQL Server 类型会怎样处理?
bit 变为 tinyint(1),money 变为 decimal(19,4),uniqueidentifier 变为 char(36),datetimeoffset 变为 UTC 的 datetime。schema 在单个数据库中变为表名前缀。不区分大小写的列改为精确比较,报告会说明是哪些列。
存储过程、触发器和视图怎么处理?
它们会按名称在报告中列出,但不会转换,因为每种数据库都用自己的语言编写它们。
脚本可以导入哪些 MySQL 版本?
MySQL 5.7 及更高版本。每个测试脚本都能在 5.7 和 9 上导入,如有问题会在第一个错误处停止。