mysql - INT(some value) - MYSQL 中的一些值的目的是什么?

标签 mysql sql

我试过写 TINYINT(1)、TINYINT(2) 和 desc 表之后;语句 MYSQL 显示它们是不同的,但是当我尝试将值放入这些字段时,实际大小是相同的 - 从 -127 到 128 或者如果它是 UNSIGNED 到 256。那么使用这个的技巧是什么,我们可以只写 TINYINT 吗? 提前致谢。

最佳答案

http://dev.mysql.com/doc/refman/5.5/en/numeric-type-attributes.html

MySQL supports an extension for optionally specifying the display width of integer data types in parentheses following the base keyword for the type. For example, INT(4) specifies an INT with a display width of four digits. This optional display width may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces. (That is, this width is present in the metadata returned with result sets. Whether it is used or not is up to the application.)

关于mysql - INT(some value) - MYSQL 中的一些值的目的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8952531/

相关文章:

mysql - 获取列值超过 X 个条目的所有行

javascript - 嘿,当使用node.js从html表单将数据插入MySql时,我不知道从哪里开始

python - 带有数据库查询的 Django charfield 模型

android - SQL计数 从GOB开始的顺序

php - 在表的字段上设置超链接

java - Solr 返回 'oldest' 条记录而不是 'newest' ; 'Rows' 和 'Start' 参数

MySQL LAST_INSERT_ID() 潜在问题

mysql - 在 INSERT 期间将值指定为另一个表中 2 列的串联

SQL 左连接给出重复的结果

sql - 在 SQL 数据库中命名 bool (位)值