How do I get actual length of value in column?
My (oracle) sql command returns maximum length of value that can be inserted in the column instead of real length of value.
How to fix this?
SQL> SELECT typ, length(t1.typ)
FROM AUTA_VIEW t1;
TYP LENGTH(T1.TYP)
---------- --------------
BMW 10
BMW 10
BMW 10
Ferrari 10
BMW 10
Audi 10
Audi 10
Audi 10
Ferrari 10
Ferrari 10
Mercedes 10
=MAX(LEN(C1:C2886)) Replace the C1:C2886 with your column and number of rows, then press Ctrl+Shift+Enter. It's very important you don't just press Enter, it won't work. The cell will now show the maximum length of the largest value for the column!
Use the built-in functions for length and max on the description column: SELECT MAX(LEN(DESC)) FROM table_name; Note that if your table is very large, there can be performance issues.
Well, you can use the LEN() function to find the length of a String value in SQL Server, for example, LEN(emp_name) will give you the length of values stored in the column emp_name.
Get the number of columns: len(df. columns) The number of columns of pandas. DataFrame can be obtained by applying len() to the columns attribute.
LENGTH()
does return the string length (just verified). I suppose that your data is padded with blanks - try
SELECT typ, LENGTH(TRIM(t1.typ))
FROM AUTA_VIEW t1;
instead.
As OraNob
mentioned, another cause could be that CHAR
is used in which case LENGTH()
would also return the column width, not the string length. However, the TRIM()
approach also works in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With