Varchar2 and Oracle quick question

Hi guys, I am using varchar2 for the product name field, but when I query the database from the SQL run command line, it shows too many empty spaces, how can I fix this without changing the datatype

here is the link to ss

http://img203.imageshack.us/img203/20/varchar.jpg

+2


a source to share


3 answers


If TRIM

does not change the results, this indicates that there are no trailing spaces in the actual database rows; they are simply added as part of the formatted screen.

By default sqlplus (the command line tool you are using) uses the maximum varchar2 column length as the (fixed) width when displaying the results of a select statement.



If you want to change this, use the column format

sqlplus command before running select. For instance:

column DEPT_NAME format a20

      

0


a source


The data inserted into the database (possibly through some ETL process) had spaces that were not trimmed.

You can update the usage (pseudocode)



Update Table Set Column = Trim(Column)

      

+1


a source



Hello

Try using cropping on both sides,
Update TableName Field Name = RTrim (LTrim (Field Name))

Hello

0


a source







All Articles