电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> SQLServer>>tinyint数据类型介绍:

tinyint数据类型介绍

来源:海水Blog | 2007-6-16 | (有15516人读过)

今天写一个新闻系统,无意中发现有的CMS中新闻ID用的是:tinyint数据类型,而不是INI,这与我以前写东西,不一样。

TINYINT支持位数小。int支持数量多。这个是我的理解!

下面是查找的相关资料:
引用
Function
Unsigned integer requiring 1 byte of storage.

Syntax
[ UNSIGNED ] TINYINT

Usage
The TINYINT data type is an exact numeric data type; its accuracy is preserved after arithmetic operations.

You can explicitly specify TINYINT as UNSIGNED, but the UNSIGNED modifier has no effect as the type is always unsigned.

The range for TINYINT values is 0 to 28 – 1, or 0 to 255.

In Embedded SQL, TINYINT columns should not be fetched into variables defined as char or unsigned char, since the result is an attempt to convert the value of the column to a string and then assign the first byte to the variable in the program. Instead, TINYINT columns should be fetched into 2-byte or 4-byte integer columns. Also, to send a TINYINT value to a database from an application written in C, the type of the C variable should be integer.

 

 

翻译:
引用
TINYINT 数据类型 [Numeric]
功能
需要 1 个字节存储的无符号整数。

语法
[ UNSIGNED ] TINYINT

用法
TINYINT 数据类型是一种精确数值数据类型;其精度在算术运算后不变。

可以将 TINYINT 显式指定为 UNSIGNED,但是该类型始终是无符号的,因此 UNSIGNED 修饰符无效。

TINYINT 值的范围是 0 到 28 – 1,即 0 到 255。

在嵌入式 SQL 中,不应该将 TINYINT 列读入定义为 char 或 unsigned char 的变量,因为这样做的结果是尝试将列的值转换为字符串,然后将第一个字节分配给程序中的变量。相反,应该将 TINYINT 列读入 2 个字节或 4 个字节的整数列。另外,若要从用 C 语言编写的应用程序向数据库中发送 TINYINT 值,变量 C 的类型应该为整数。

 

INT 或 INTEGER 数据类型 [Numeric]

引用
功能
需要 4 个字节存储的整数。

语法
[ UNSIGNED ] { INT | INTEGER }

用法
INTEGER 数据类型是精确数值数据类型,其精度在算术运算后不变。

如果您指定 UNSIGNED,则整数永远不能被指定为负数。缺省情况下,数据类型是带符号的。

有符号的整数值的范围是 –231 到 231 – 1,即 –2147483648 到 2147483647。

无符号的整数值范围是 0 到 232 – 1,即 0 到 4294967295。



www.cncfan.com提示,请保留原作者信息:
文章归属信息 -
作者:海水
地址:http://www.haishui.net/blog/read.php?166

SQLServer热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号