title: How to add a not null constraint to an already existing column with null values?
body: <p>I've seen a similar question on stackexchange, but it's answer did not give me the correct results.</p>
  
  <p>For demonstration purposes, I have a simple table <code>PURCHASES</code> with columns <code>PURCHASE_NUM</code>, <code>PURCHASE_DATE</code>, <code>CUSTOMER_ID.</code>  I want to enforce a not null constraint on the <code>CUSTOMER_ID</code> table.  I tried the following:</p>
  
  <pre><code>ALTER TABLE PURCHASES MODIFY CUSTOMER_ID char NOT NULL;
  </code></pre>
  
  <p>That syntax is fine, but then I insert with the following: <code>INSERT INTO PURCHASES VALUES (333, NULL, NULL);</code> and the tuple is added without issue.  Why is the constraint not being enforced?  Would having NULL values already in that column before adding the constraint affect things?</p>
  
  <p>Thanks</p>
  
  <p><em>edit</em> <code>DESCRIBE PURCHASES;</code> says the following for the column of interest:</p>
  
  <pre><code>Field, Type, Null, Key, Default, Extra
  CUSTOMER_ID, char(5), YES, , NULL, 
  </code></pre>