sqlserver与mysql数据类型对应

Integer

MySQLMS SQL ServerConversion remarks
TINYINT tinyint tinyint is unsigned
SMALLINT smallint -
MEDIUMINT int int stores data on 4 bytes
INT
BIGINT bigint -

Decimal

MySQLMS SQL ServerConversion remarks
DECIMAL(M,D) decimal(p,s) The maximum precision is 38, while the default is 18. The default scale is 0.

浮点精度数据类型用于精度大于38的小数。

 
Advertisement

 

Floating Point

MySQLMS SQL ServerConversion remarks
FLOAT(N) float(n) -
FLOAT(M,D) float(24) SQL Server does not allow the non-standard syntax
DOUBLE(M,D) float(53) SQL Server does not allow the non-standard syntax
REAL(M,D)

Date and Time

MySQLMS SQL ServerConversion remarks
DATETIME datetime2 Date values start at 0001-01-01
DATE date Date values start at 0001-01-01
TIME time timerange is 00:00:00.0000000 through 23:59:59.9999999
TIMESTAMP smalldatetime smalldatetime value range is 1900-01-01 through 2079-06-06
YEAR smallint -


MS SQL Server不能将零存储为月份或日期。

 

String

MySQLMS SQL ServerConversion remarks
CHAR nchar(n) nchar allows 4000 characters
VARCHAR nvarchar(n|max) nvarchar allows 4000 characters but max indicates maximum storage size of 2^31-1 bytes.
TINYTEXT
TEXT(M)
MEDIUMTEXT
LONGTEXT


字符串常量中的\'转义序列应替换为双引号字符。

Binary

 

MySQLMS SQL ServerConversion remarks
BINARY(M) binary(n) binary allows 8000 bytes
VARBINARY(M) varbinary(n|max) nvarbinary allows 8000 bytes but max indicates maximum storage size of 2^31-1 bytes.
TINYBLOB
BLOB
MEDIUMBLOB
LONGBLOB

 

https://www.mssqltips.com/sqlservertutorial/2203/mysql-to-sql-server-data-type-comparisons/

 

posted @ 2020-05-20 15:55  代码/改变世界  阅读(4197)  评论(0编辑  收藏  举报