关于 NULL 本页介绍天翼云TeleDB数据库中关于NULL的判断和处理方案。 1. NULL的判断:IS NULL,IS NOT NULL。 注意 boolean 类型取值 true,false,NULL。 NOT IN 集合中带有 NULL 元素。 teledb select from toids; id name birth city +++ 1 张三 20001201 00:00:00 北京 2 李四 19970324 00:00:00 上海 3 王五 20040901 00:00:00 广州 (3 rows) teledb select from toids where id not in (null); id name birth city +++ (0 rows) 2. 建议对字符串型NULL 值处理后,再进行 操作。 teledb select id,name from toids limit 1; id name + 1 张三 (1 row) teledb select id,namenull from toids limit 1; id ?column? + 1 (1 row) teledb select id,name coalesce(null,'') from toids limit 1; id ?column? + 1 张三 (1 row) 注意 开启oracle兼容后,可无需处理。 teledb set enableoraclecompatible to on; SET teledb select id,namenull from toids limit 1; id ?column? + 1 张三 (1 row) 3. 建议使用count(1) 或 count() 来统计行数,而不建议使用 count(col) 来统计行数,因为 NULL 值不会计入。 说明 count(多列列名)时,多列列名必须使用括号,例如count( (col1,col2,col3) ),注意多列的count,即使所有列都为NULL,该行也被计数,所以效果与count()一致。 teledb