MySQL的布尔" TINYINT(1)QUOT;拥有价值达127? [英] MySQL Boolean "tinyint(1)" holds values up to 127?

查看:147
本文介绍了MySQL的布尔" TINYINT(1)QUOT;拥有价值达127?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想作一个真/假字段,如果一个产品的库存。

I wanted to make a true/false field for if an item is in stock.

我想将它设置为布尔(这被转换为 TINYINT(1)),1个在股票,0为没有现货。

I wanted to set it to Boolean ( which gets converted to tinyint(1) ), 1 for in stock, 0 for not in stock.

我收到来自厂商供稿,所以我对自己说,如果他们通过多少人的inStock?

I am getting feeds from vendors, so I thought to myself, "What if they pass how many are instock?"

所以我想,如果我插入一个数字大于1,会发生什么。我以为它会默认为1。

So I wondered if I inserted a number higher than 1 what would happen. I assumed it would default to 1.

要我吃惊的是它能让我抱任何数量多达127个,比默认什么127。

To my surprise it will allow me to hold any number up to 127, anything over defaults to 127.

任何人能解释为什么吗?

Can anyone explain why?

推荐答案

签署的 TINYINT 数据类型可以存储-128到127之间的整数值。

The signed TINYINT data type can store integer values between -128 and 127.

然而, TINYINT(1)不改变最小或最大值可以存储。它只是说要的显示的,只有当该类型的值作为打印输出。一个数字

However, TINYINT(1) does not change the minimum or maximum value it can store. It just says to display only one digit when values of that type are printed as output.

这篇关于MySQL的布尔" TINYINT(1)QUOT;拥有价值达127?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆