Extra spaces are added to the tail in the column.

When I save the data in a table, extra spaces are added to the value in the tail. I noticed that since the column length is 5, if I insert a value of 3 char length, 2 extra spaces are added. Can anyone solve this problem.

+7
source share
3 answers

Is the column type CHAR(5) instead of VARCHAR(5) ?

  • CHAR(x) creates a column that always stores x characters and fills data with spaces.
  • VARCHAR(x) creates a column that changes the length of the rows according to the data entered.
+21
source

This property is of type CHAR . If you do not want extra spaces, you need to use VARCHAR , although for a small field the minimum overhead compared to the standard CHAR . Having said that, it is believed that VARCHAR is currently no worse than CHAR .

+4
source

CHAR variables will store this extra addition, maybe you need to use VARCHAR2 variables instead?

0
source

All Articles