Oracle 10g:列为空,但不为空或空字符串
我的表中有一个空白列。奇怪的是它似乎不是 null 或空字符串。所以,如果我这样做:
SELECT *
FROM TABLE
WHERE column IS NULL
……或者:
SELECT *
FROM TABLE
WHERE column = ''
我什么也得不到。想法?
I have a column in a table that is blank. The weird thing is that it does not appear to be null or an empty string. So, if I do this:
SELECT *
FROM TABLE
WHERE column IS NULL
...or:
SELECT *
FROM TABLE
WHERE column = ''
I get nothing. Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
发出此查询:
它将显示确切的内容。
相关:Oracle不允许空字符串;它们会默默地转换为
NULL
。Issue this query:
It'll show the exact contents.
Related: Oracle does not allow empty strings; they're silently converted to
NULL
.也许该列只包含空格?
你尝试过吗
Maybe the column contains only spaces?
Did you try
Oracle 有一个基本上永久的烦恼,即空字符串被视为 null。但是,您确定这是一个空字符串吗?它可能是其他不可见的字符,例如空格或制表符/换行符/换行符/等等...当您
从表中选择长度(列)
时,字符串长度显示什么?Oracle's got a basically permanent annoyance that empty strings are treated as null. However, are you sure that's an empty string? It could be an otherwise invisible character, such as a space or tab/linebreak/linefeed/etc... What does the string length show when you do
select length(column) from table
?试试这个:
Try this:
如果您的列不是
VARCHAR2
而是CHAR(N)
,则将填充空字符串的插入。请参阅 Tom Kyte 讲述的内容关于这个If your column is not
VARCHAR2
butCHAR(N)
then insertion of an empty string is padded. See what Tom Kyte tells about this