当前位置:网站首页>Detailed explanation of SQL Sever basic data types

Detailed explanation of SQL Sever basic data types

2022-06-24 10:39:00 Cpsu

Classification and data characteristics data type ( Case insensitive )
Integer data type BIT 、INT、SAMLLINT、TINYINT
Currency data types MONEY、SMALLMONEY
Floating point data types REAL、FLOAT、DECIMAL、NUMERIC
date / Time data type DATETIME、SMALLDATETIME、DATA、DATETIME(2)、DATETIMESTAMPOFFSET
Character data type CHAR、NCHAR(n)、VARCHAR、NVARCHAR(n)
Binary data type BINARY、VARBINARY
Image and text data types TEXT、NTEXT(n)、IMAGE

Character data type

char: Fixed length , Storage ANSI character , Fill in the blanks .

nchar(n): Fixed length , Storage Unicode character , Fill in the blanks

varchar: Variable length , Storage ANSI character , Automatically change according to the length of the data .

nvarchar(n): Variable length , Storage Unicode character , Automatically change according to the length of the data .

If you are sure of the length of the stored data , And it doesn't include Chinese , You can choose char type .

If the length of the stored data is certain , But it may include Chinese , You can choose nchar type .

If you are unsure of the length of the stored data , Storage only in English 、 The best use of numbers varchar

If you are unsure of the length of the stored data , There may also be Chinese , You can choose nvarchar type , stay SQL Server2005 Is also a commonly used character data type .
Link to the original text :https://www.cnblogs.com/flyrock/archive/2012/07/08/2581234.html

Floating point data type reference :
https://www.cnblogs.com/Sungeek/p/12167796.html

Currency data type reference :
https://docs.microsoft.com/zh-cn/sql/t-sql/data-types/money-and-smallmoney-transact-sql?view=sql-server-2017

date / Time data type reference :
https://blog.csdn.net/qq_39019865/article/details/81061521

Integer data type reference :
https://www.cnblogs.com/ButterflyEffect/p/8944706.html

Image and text type reference :
https://blog.csdn.net/lishimin1012/article/details/50526988

原网站

版权声明
本文为[Cpsu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240912595778.html