When I am saving data into a table, extra spaces being added to the valued at the tail. I observed that as the column length is 5, if I am inserting a value of 3 char length, 2 extra spaces are being added. Can any one how to solve this problem.
Is the column type CHAR(5)
instead of VARCHAR(5)
?
CHAR(x)
creates a column that always stores x characters, and pads the data with spaces.VARCHAR(x)
creates a column that varies the lengths of the strings to match the data inserted.