title: Postgresql - change the size of a varchar column to lower length
body: <p>I have a question about the <code>ALTER TABLE</code> command on a really large table (almost 30 millions rows).
  One of its columns is a <code>varchar(255)</code> and I would like to resize it to a <code>varchar(40)</code>.
  Basically, I would like to change my column by running the following command:</p>
  <pre class="lang-sql prettyprint-override"><code>ALTER TABLE mytable ALTER COLUMN mycolumn TYPE varchar(40);
  </code></pre>
  <p>I have no problem if the process is very long but it seems my table is no more readable during the <code>ALTER TABLE</code> command.
  Is there a smarter way? Maybe add a new column, copy values from the old column, drop the old column and finally rename the new one?</p>
  <p><strong>Note:</strong> I use PostgreSQL 9.0.</p>