title: Are databases single-threaded?
body: <p>Let's say there is a hospital that runs a simple database. In this database is a table called "patients" with 1,000,000 records--each record being a patient whose status is either "active" or "discharged".</p>
  
  <p>Bob runs the following query that will take a few seconds or maybe minutes to run:</p>
  
  <pre><code>SELECT COUNT(*) FROM PATIENTS WHERE STATUS = "active"
  </code></pre>
  
  <p>At the moment Bob <em>begins</em> execution of the query, 100 patients are active.</p>
  
  <p>However, while the query is running, Susie runs the following command on the table:</p>
  
  <pre><code>UPDATE PATIENTS SET STATUS = "discharged" WHERE PATIENT_ID = 583739789
  </code></pre>
  
  <p>This command discharges one of the active patients, changing the real "active" patient count to 99.</p>
  
  <p>After Susie does this, Bob's query finishes. Will the result of his query be 100 or 99 active patients? How do the different databases handle this (Oracle, MySQL, SQLite, etc)?</p>