A CHAR column has a fixed size. If the string value is shorter than the column’s stated size, it will be padded with blank spaces until it meets that size. Thus, table size can be significantly reduced by decreasing the declared CHAR length.
The CHAR data type should be used when all the values have the same length. Otherwise, it is better to choose VARCHAR.
Let’s use a simple shop diagram as an example:
The Purchase
table has a column called purchase_no
. As the purchase number always has a fixed length of 12 characters, the best choice for this column’s data type is CHAR. Its size should be set to 12, as there is no need to assign anything higher.
Changing a CHAR field’s length in Vertabelo is very easy. First, select the table. Then, go to the Column section on the right and click the gear icon next to the column type .
A new window with the available data types will appear. The CHAR data type can be found in the String section. Next to the data type selected, there’s an area to configure the maximum length.
Alternatively, you can change a CHAR field length manually by modifying the number inside brackets in the Type field: