<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>I, too, prefer NULL, but... on FromDual GmbH</title><link>https://www.fromdual.com/blog/using-null-as-default-values/comment-259/</link><description>Recent content in I, too, prefer NULL, but... on FromDual GmbH</description><generator>Hugo</generator><language>en-GB</language><managingEditor>oli.sennhauser@fromdual.com (Oli Sennhauser)</managingEditor><webMaster>oli.sennhauser@fromdual.com (Oli Sennhauser)</webMaster><copyright>© FromDual GmbH</copyright><lastBuildDate>Sat, 06 Aug 2011 13:19:17 +0200</lastBuildDate><atom:link href="https://www.fromdual.com/blog/using-null-as-default-values/comment-259/index.xml" rel="self" type="application/rss+xml"/><item><title>I, too, prefer NULL, but...</title><link>https://www.fromdual.com/blog/using-null-as-default-values/comment-259/</link><pubDate>Sat, 06 Aug 2011 13:19:17 +0200</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/using-null-as-default-values/comment-259/</guid><description>&lt;p&gt;If you&amp;rsquo;re using NULL to represent &amp;ldquo;anytime in the past/future&amp;rdquo; for DATETIME, that means that you need &amp;ldquo;special handling&amp;rdquo; for what would otherwise be simple inequalities.&lt;/p&gt;
&lt;p&gt;For examples, I often store validity ranges with DATETIME; but that means I can no longer query if &amp;ldquo;valid_from &amp;gt; &amp;lsquo;2011-07-22 00:00:00&amp;rsquo;&amp;rdquo;, since that will through out any ( valid_from = NULL ) records. That&amp;rsquo;s not what I mean here &amp;ndash; if the valid_from is NULL, that means they are &lt;em&gt;always&lt;/em&gt; valid.&lt;/p&gt;
&lt;p&gt;So in these particular cases, I prefer to use &amp;lsquo;0&amp;rsquo; and &amp;lsquo;9999-12-31&amp;rsquo; as special values so that index usage is correct and WHERE clauses are simplified.&lt;/p&gt;
&lt;p&gt;But otherwise, yes, if NULL means &amp;ldquo;unknown&amp;rdquo;, as opposed to &amp;ldquo;special&amp;rdquo;, I entirely agree.&lt;/p&gt;</description></item></channel></rss>