MySQL INT类型可以是非零NULL [英] Can MySQL INT type be non-zero NULL

查看:131
本文介绍了MySQL INT类型可以是非零NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个MySQL数据库,它由每周数据集组成,可追溯到过去十年。最近的记录中存在一些数据点,但在某些较旧的数据集中未跟踪这些数据点。有问题的字段都包含整数值,'0'是跟踪数据点的记录的完全有效(和频繁)值。我需要能够区分零值和不存在的数据。因此,我需要找出是否可以为INT类型存储未表示为0的NULL(读取:BLANK CELL)。但是,传递给DB的NULL值表示为'0'(至少,它们在phpMyAdmin中),有没有办法改变它?

I'm creating a MySQL DB which is composed of weekly data sets, going back for the past decade. There are some data points which exist for recent records, but which were not tracked in some of the older data sets. The fields in question all contain integer values, and '0' is a perfectly valid (and frequent) value for the records which did track the data points. I need to be able to distinguish between a value of zero and non-existent data. Therefore, I need to find out if it is possible to store a NULL which is not represented as a '0' (read: BLANK CELL) for an INT type. However, NULL values passed to the DB are represented as '0' (at least, they are in phpMyAdmin), is there any way to change this?

谢谢你的帮帮我。

推荐答案

您可以将值设置为NULL。 INSERT INTO表(INT_COLUMN)VALUES(NULL)是有效的SQL(INT_COLUMN是可以为空的int列)。

You can set the value to NULL. INSERT INTO table (INT_COLUMN) VALUES (NULL) is valid SQL (with INT_COLUMN being a nullable int column).

这篇关于MySQL INT类型可以是非零NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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