Find the length of the longest row in a column in oracle

后端 未结 9 1523
野趣味
野趣味 2020-12-16 14:19

Does anybody know if there is a way to find what the length of the longest row in a column in Oracle?

Basically I need to get the length of the longest row and then

相关标签:
9条回答
  • 2020-12-16 14:43

    To make the maxlength useable you may want to get it from a imbedded select

    select <do something with maxlength here> 
    from
    (select x.*, 
    ( select max(length(yourcolumn)) from yourtable) as maxlength 
    from yourtable x)
    
    0 讨论(0)
  • 2020-12-16 14:44

    This should do what you want:

    select max(length(MyColumn)) from MyTable;
    

    Depending on what you are trying to achieve, you may also be insterested to know that you can output the data in the column plus exactly one space like this:

    select rtrim(MyColumn)||' ' from MyTable;
    
    0 讨论(0)
  • 2020-12-16 14:44

    To pad all values in a column to the longest value +1 you can do:

    SELECT RPAD( column_name ,(SELECT MAX(LENGTH( column_name ))+1 FROM table)) FROM table;
    
    0 讨论(0)
提交回复
热议问题