title: Find the length of the longest row in a column in oracle
body: <p>Does anybody know if there is a way to find what the length of the longest
  row in a column in Oracle?</p>
  <p>Basically I need to get the length of the longest row and then use that length plus 1
  with <code>SUBSTR</code> to make the output of the column one character longer than the longest string.</p>
  <hr />
  <p>However, the <code>MAX(LENGTH(column_name)) AS MAXLENGTH</code> approach gives me the number I want but when I try to use it with <code>SUBSTR(column_name,1, MAXLENGTH)</code> I get an invalid identifier error.</p>
  <p>SO I made a function to return the numberI wanted then used:</p>
  <pre><code>SUBSTR(column_name,1,maxlengthfunc)
  </code></pre>
  <p>This gave me the following output:</p>
  <pre><code>SUBSTR(NAME,1,MAXLENGTHFUNC)
  </code></pre>
  <p>Rather than:</p>
  <pre><code>SUBSTR(NAME, 1, 19)
  </code></pre>
  <p>And it didn't shrink the output column size like I needed.</p>
  <p>Also</p>
  <pre><code>RTRIM(name)||' '
  </code></pre>
  <p>didn't work when run.</p>