Reproduce
drop table if exists test_tinyint;
create table test_tinyint (
num tinyint
) engine=innodb charset=utf8;
insert into test_tinyint values(-100);
insert into test_tinyint values(255);
执行第7行的代码时候报错"Out of range value for column ’num’ at row 7",这其实是因为(Signed 的) TINYINT
的范围是 -128 到 127,而 255 超过了这个范围。
如果把第3行的num字段定义改为"num tinyint unsigned",第7行的插入就不会报错了。但是第6行的插入-100又报错了,因为无符号整型是无法表示负数的。
Reference
FEATURED TAGS
algorithm
algorithmproblem
architecturalpattern
architecture
aws
c#
cachesystem
codis
compile
concurrentcontrol
database
dataformat
datastructure
debug
design
designpattern
distributedsystem
django
docker
domain
engineering
freebsd
git
golang
grafana
hackintosh
hadoop
hardware
hexo
http
hugo
ios
iot
java
javaee
javascript
kafka
kubernetes
linux
linuxcommand
linuxio
lock
macos
markdown
microservices
mysql
nas
network
networkprogramming
nginx
node.js
npm
oop
openwrt
operatingsystem
padavan
performance
programming
prometheus
protobuf
python
redis
router
security
shell
software testing
spring
sql
systemdesign
truenas
ubuntu
vmware
vpn
windows
wmware
wordpress
xml
zookeeper