What is the difference between the various character types?
TypeInternal NameNotes VARCHAR(n)varcharsize specifies maximum length, no padding CHAR(n)bpcharblank padded to the specified fixed length TEXTtextno specific upper limit on length BYTEAbyteavariable-length byte array (null-byte safe) “char”charone character You will see the internal name when examining system catalogs and in some error messages. The first four types above are “varlena” types (i.e., the first four bytes on disk are the length, followed by the data). Thus the actual space used is slightly greater than the declared size. However, long values are also subject to compression, so the space on disk might also be less than expected. VARCHAR(n) is best when storing variable-length strings and it limits how long a string can be. TEXT is for strings of unlimited length, with a maximum of one gigabyte. CHAR(n) is for storing strings that are all the same length. CHAR(n) pads with blanks to the specified length, while VARCHAR(n) only stores the characters supplied.
TypeInternal NameNotes VARCHAR(n)varcharsize specifies maximum length, no padding CHAR(n)bpcharblank padded to the specified fixed length TEXTtextno specific upper limit on length BYTEAbyteavariable-length byte array (null-byte safe) “char”charone character You will see the internal name when examining system catalogs and in some error messages. The first four types above are “varlena” types (i.e., the first four bytes on disk are the length, followed by the data). Thus the actual space used is slightly greater than the declared size. However, long values are also subject to compression, so the space on disk might also be less than expected. VARCHAR(n) is best when storing variable-length strings and it limits how long a string can be. TEXT is for strings of unlimited length, with a maximum of one gigabyte. CHAR(n) is for storing strings that are all the same length. CHAR(n) pads with blanks to the specified length, while VARCHAR(n) only stores the characters supplied. BYTEA is for sto