資料型別

位元數

資料範圍

tinyint

 1 Byte

0 ~ 2^8 -1
( 0 ~ 255 )

smallint

 2 Bytes

-2^15 ~ 2^15-1
( -32738 ~ 32767 )

int

 4 Bytes

-2^31 ~ 2^31 -1
( -2147483648 ~ 2147483467)

bigint

 8 Bytes

-2^63~2^63 -1
(-9223372036854775808 ~ 9223372036854776807 )

bit

 1 Byte

 0 , 1 , Null

精確位數與浮點數

資料型別

位元數

資料範圍

numeric

視精確度而定

-10^38 +1 ~ 10^38 -1

decimal

視精確度而定

-10^38 +1 ~ 10^38 -1

float

 8 Bytes

 -1.79E+308 ~ 1.79E+308
15
位數

real

 4 Bytes

-3.40E+38 ~ 3.40E+38
  7
位數

字串 - Unicode 字串 - Binary 字串

資料型別

位元數

資料範圍

 char(n)

1字元 1Byte

 1 ~ 8000 字元

 varchar(n)

1字元 1Byte

 1 ~ 8000 字元

 varchar(max)

變動長度 max=2GB

 1 ~ 2^31 -1 字元

 text

變動長度 max=2GB

 1 ~ 2^31 -1 字元

 nchar(n)

1字元 2Byte

 1 ~ 4000 字元

 nvarchar(n)

1字元 2Byte

 1 ~ 4000 字元

 nvarchar(max)

1字元 2Byte
變動長度 max=2GB

 1 ~ 2^30 -1 字元

 ntext

1字元 2Byte
變動長度 max=2GB

 1 ~ 2^30 -1 字元

 binary(n)

固定長度 8000 Bytes,不足自動補上 0x00

 1 ~ 8000 Bytes

 varbinary(n)

變動長度

 1 ~ 8000 Bytes

 varbinary(max)

變動長度 max=2GB

 1 ~ 2^31 -1 Bytes

 image

變動長度 max=2GB

 1 ~ 2^31 -1 Bytes

日期 - 時間 - 貨幣 - Timestamp

資料型別

位元數

資料範圍

datatime

 8 Bytes

1753/1/1 ~ 9999/12/31
ex: 2008-11-27 08:08:08.888

smalldatatime

 4 Bytes

1900/1/1 ~ 2079/6/6
ex: 2008-11-24 15:11

money

 8 Bytes

 -2^63 ~ 2^63 -1 小數4
( -922337203685477.5808 ~ 922337203685477.5807)

smallmoney

 4 Bytes

-2^31 ~ 2^31 -1 小數4  
( -214748.3648 ~ 214748.3647) 

timestamp

 8 Bytes

8 Bytes   16 進位值

uniqueidentifier

 16 Bytes

16 Bytes 16 進位值

arrow
arrow
    全站熱搜

    軒軒的爸媽 發表在 痞客邦 留言(0) 人氣()