title: SQL compound unique key with null
body: <p>This is how I create the table:</p>
  <pre><code>CREATE  TABLE IF NOT EXISTS division (
  DIV_ID INTEGER PRIMARY KEY ,
  DIV_CODE VARCHAR(10) ,
  DIV_NAME VARCHAR(20) ,
  GR_ID INTEGER ,
  UNIQUE (DIV_CODE, DIV_NAME, GR_ID) ,
  CONSTRAINT FK1 FOREIGN KEY (GR_ID) REFERENCES grade(GR_ID) )
  </code></pre>
  <p>If a row exists where <code>DIV_CODE=&quot;1&quot;</code>, <code>DIV_NAME=&quot;1&quot;</code> and <code>GR_ID=1</code>, and I try inserting another row with values &quot;1&quot;, &quot;1&quot; and 1, then I get a SQL integrity error, which is expected.</p>
  <p>If a row exists where <code>DIV_CODE=&quot;1&quot;</code>, <code>DIV_NAME=&quot;1&quot;</code> and <code>GR_ID=null</code>, and I try inserting another row with vales &quot;1&quot;, &quot;1&quot; and null, then the new row is inserted. I now have 2 rows with the same values for each column. Can I setup the table differently to get a similar integrity error for this scenario?</p>
  <p>Thanks</p>
  <p>EDIT
  removed <code>NOT NULL</code> from <code>GR_ID</code> definition.</p>