title: Best practices for SQL varchar column length
body: <p>Every time is set up a new SQL table or add a new <code>varchar</code> column to an existing table, I am wondering one thing: what is the best value for the <code>length</code>. </p>
  
  <p>So, lets say, you have a column called <code>name</code> of type <code>varchar</code>. So, you have to choose the length. I cannot think of a name > 20 chars, but you will never know. But instead of using 20, I always round up to the next 2^n number. In this case, I would choose 32 as the length. I do that, because from an computer scientist point of view, a number 2^n looks more <code>even</code> to me than other numbers and I'm just assuming that the architecture underneath can handle those numbers slightly better than others.</p>
  
  <p>On the other hand, MSSQL server for example, sets the default length value to 50, when you choose to create a varchar column. That makes me thinking about it. Why 50? is it just a random number, or based on average column length, or what?</p>
  
  <p>It could also be - or probably is - that different SQL servers implementations (like MySQL, MSSQL, Postgres, ...) have different best column length values.</p>