sqlserver與mysql數據類型對應


Integer

MySQL MS SQL Server Conversion remarks
TINYINT tinyint tinyint is unsigned
SMALLINT smallint -
MEDIUMINT int int stores data on 4 bytes
INT
BIGINT bigint -

Decimal

MySQL MS SQL Server Conversion 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

MySQL MS SQL Server Conversion 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

MySQL MS SQL Server Conversion 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

MySQL MS SQL Server Conversion 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

 

MySQL MS SQL Server Conversion 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/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM