异构关系数据库(Sqlserver与MySql)之间的数据类型转换参考
一、SqlServer到MySql的数据类型的转变
编号 |
SqlServer |
ToMySql |
MySql |
1 |
binary(50) |
LONGBLOB |
binary |
2 |
bit |
CHAR(1) |
bit |
3 |
char(10) |
VARCHAR(10) |
char |
4 |
date |
VARCHAR(10) |
date |
5 |
datetime |
UNKNOWN |
datetime |
6 |
datetime2(7) |
VARCHAR(27) |
datetime |
7 |
datetimeoffset(7) |
VARCHAR(34) |
datetime |
8 |
decimal(18, 0) |
BIGINT |
decimal |
9 |
float |
DOUBLE |
float |
10 |
nchar(10) |
Varchar(10) |
nvarchar(10) |
11 |
numeric(18, 0) |
BIGINT |
real |
12 |
nvarchar(50) |
VARCHAR(50) |
nvarchar(50) |
13 |
nvarchar(MAX) |
MEDIUMTEXT |
nvarchar |
14 |
real |
DOUBLE |
real |
15 |
smallmoney |
DOUBLE |
decimal(10,4) |
16 |
text |
MEDIUMTEXT |
text |
17 |
time(7) |
VARCHAR(16) |
time |
18 |
timestamp |
LONGBLOB |
timestamp |
19 |
varbinary(50) |
LONGBLOB |
varbinary |
20 |
varbinary(MAX) |
LONGBLOB |
varbinary |
21 |
varchar(MAX) |
MEDIUMTEXT |
varchar |
22 |
uniqueidentifier |
VARCHAR(36) |
VARCHAR(36) |
23 |
geography |
LONGBLOB |
LONGBLOB |
24 |
geometry |
LONGBLOB |
LONGBLOB |
25 |
hierarchyid |
LONGBLOB |
LONGBLOB |
26 |
bigint |
BIGINT |
bigint |
27 |
image |
LONGBLOB |
longblob |
28 |
int |
INT |
int |
29 |
money |
DECIMAL(19,4) |
decimal(19,4) |
30 |
ntext |
MEDIUMTEXT |
mediumtext |
31 |
smalldatetime |
DATETIME |
datetime |
32 |
smallint |
INT |
int |
33 |
sql_variant |
TEXT |
text |
34 |
tinyint |
INT |
int |
35 |
Varchar(50) |
VARCHAR(50) |
Varchar(50) |
36 |
xml |
MEDIUMTEXT |
mediumtext |
二、MySql到Sqlserver的数据类型的转变
编号 |
MySql |
ToSqlServer |
SqlServer |
1 |
DECIMAL/DECIMAL(10) |
BIGINT |
DECIMAL |
2 |
BLOB |
VARCHAR(100) |
IMAGE |
3 |
BLOB(10) |
VARCHAR(100) |
IMAGE |
4 |
BINARY |
UNKNOWN |
BINARY |
5 |
LONGBLOB |
VARCHAR(100) |
IMAGE |
6 |
MEDIUMBLOB |
VARCHAR(100) |
IMAGE |
7 |
TINYBLOB |
VARCHAR(100) |
IMAGE |
8 |
VARBINARY(10) |
VARCHAR(100) |
VARBINARY |
9 |
DATE |
DATETIME |
DATE |
10 |
TIME |
DATETIME |
TIME |
11 |
TIMESTAMP |
DATETIME |
TIMESTAMP |
12 |
YEAR |
DATETIME |
INT |
13 |
DECIMAL(10) |
BIGINT |
DECIMAL |
14 |
DOUBLE |
FLOAT(53) |
REAL |
15 |
REAL |
FLOAT(53) |
REAL |
16 |
CHAR |
VARCHAR |
CHAR |
17 |
NVARCHAR |
VARCHAR |
NVARCHAR |
18 |
TEXT |
VARCHAR |
TEXT |
19 |
TINYTEXT |
VARCHAR |
TEXT |
20 |
BIT |
VARCHAR |
BIT |
21 |
ENUM |
VARCHAR |
VARCHAR2 |
22 |
SET |
VARCHAR |
VARCHAR2 |
23 |
GEOMETRY |
UNKNOWN |
TEXT |
24 |
GEOMETRYCOLLECTION |
UNKNOWN |
TEXT |
25 |
MULTILINESTRING |
UNKNOWN |
TEXT |
26 |
LINESTRING |
UNKNOWN |
TEXT |
27 |
MULTIPOINT |
UNKNOWN |
TEXT |
28 |
MULTIPOLYGON |
UNKNOWN |
TEXT |
29 |
POINT |
UNKNOWN |
TEXT |
30 |
POLYGON |
UNKNOWN |
TEXT |
31 |
INT |
INT |
INT |
32 |
VARCHAR(20) |
VARCHAR(20) |
VARCHAR(20) |
33 |
DATETIME |
DATETIME |
DATETIME |
34 |
DATETIME(6) |
DATETIME |
DATETIME |
35 |
FLOAT |
FLOAT |
FLOAT |
36 |
INT(8) |
INT |
INT |
37 |
MEDIUMINT(10) |
INT |
INT |
38 |
SMALLINT(2) |
INT |
INT |
39 |
TINYINT(2) |
INT |
INT |
40 |
LONGTEXT |
TEXT |
TEXT |
41 |
MEDIUMTEXT |
TEXT |
TEXT |