c#数据类型 与sql的对应关系 以及 取值范围

本文深入探讨了SQL中常用的数据类型,包括整型、浮点型、布尔型、数值型、位型等,并详细解释了每种类型的取值范围、SQL数据类型匹配以及在表定义中可能使用的约束。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

Short Name.NET ClassTypeWidthRange (bits)SQL Datatype (Closest Match)Constraint to use (if needed in table definition)

byte

Byte

Unsigned integer

8

0 to 255

tinyint 

sbyte

SByte

Signed integer

8

-128 to 127

smallint[ColName] Between -128 AND 127

int

Int32

Signed integer

32

-2,147,483,648 to 2,147,483,647

int 

uint

UInt32

Unsigned integer

32

0 to 4294967295

bigint[ColName] Between 0 AND 4294967295

short

Int16

Signed integer

16

-32,768 to 32,767

smallint 

ushort

UInt16

Unsigned integer

16

0 to 65535

int[ColName] Between 0 AND 65535

long

Int64

Signed integer

64

-922337203685477508 to 922337203685477507

bigint 

ulong

UInt64

Unsigned integer

64

0 to 18446744073709551615

decimal(20,0)[ColName] Between 0 AND 18446744073709551615

float

Single

Single-precision floating point type

32

-3.402823e38 to 3.402823e38

real 

double

Double

Double-precision floating point type

64

-1.79769313486232e308 to 1.79769313486232e308

float 

bool

Boolean

Logical Boolean type

8

True or false

bit 

decimal

Decimal

Precise fractional or integral type that can represent decimal numbers with 29 significant digits

128

±1.0 × 10e-28 to ±7.9 × 10e28

decimal (can go 38 significant in SQL need to limit to 29 for here.) 



转载于:https://www.cnblogs.com/duanweishi/p/4498044.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值