title: Why Specify a Length for an Auto Increment ID
body: <p>I have been working with SQL for about 2 years now, and it has always been on my mind. </p>
  
  <blockquote>
    <p>Best practices say assign the length of the column to what you are
    expecting</p>
  </blockquote>
  
  <p>The SQL wants a specific row dedicated as a Primary key but it's also in best practice for an A_i field... But what length to assign it? If left blank it defaults to <em>11</em>, which represents <em>999,999,999</em></p>
  
  <p>Which seems fine, but best practices also state never to actually clear anything from a database; just append a 0 or 1 to represent deleted, this is for archival/recovery purposes.. Also can be used for auditing of what users want to clear..</p>
  
  <p><em>Take this example:</em></p>
  
  <p>I have a website which is around for years, following the best practices in terms of not deleting anything from the database; my database/website traffic is very heavy with tons of unique users/visitors per day.</p>
  
  <p>Now, if I leave the SQL default length of 11, what would happen if my table reaches the maximum length and then another user decides to register? It would throw an error and not continue, which will bring up a small amount of downtime for new users reason being is that a Database administrator will have to login to the SQL and change the length.. Which is not much effort, but it IS effort which can be avoided during the early development..</p>
  
  <hr>
  
  <p>What I do, when creating a table is give a length of <em>255</em> which in the back of my mind, something is telling me 'this is not good practice' but it avoids the very slim possibility of the example stated above.</p>
  
  <p>When compared to a <code>text</code> field, which does not have a specified length, why cannot this be the same in terms of an A_I field.</p>
  
  <p>Don't get me wrong, I completely understand the data types available.</p>
  
  <hr>
  
  <p>I have performed an amount of research both through google and SO, but the results have pointed to questions about altering the table to increase the current length. This is not what i'm asking for.</p>
  
  <hr>
  
  <p><strong>Overall:</strong></p>
  
  <p>So overall, what I am trying to ask; what is  the ideal length for an A_I field? to minimize the slim risk of an error being thrown if it maxes out the length but also keeping best practices in mind.</p>