SQL Server
CREATE TABLE t (c CHAR(10), v VARCHAR(10));
CHAR pads on storage; trailing spaces are ignored in equality ('a' = 'a ' is true), and ANSI_PADDING is effectively always ON in modern versions.
Blank-padding is invisible until a join compares CHAR to VARCHAR and stops matching.
Filed under Types & casting
CHAR buys nothing in modern engines except fixed-width semantics you almost never want; TEXT/VARCHAR2/VARCHAR is the default everywhere. If you inherit CHAR columns, test comparisons against VARCHAR values: trailing-space rules differ per engine and, in MySQL, per collation.
CHAR(n) pads short values with spaces; VARCHAR does not. What happens to those spaces on read and in comparisons is where the dialects quietly disagree, and SQLite never pads at all.
CREATE TABLE t (c CHAR(10), v VARCHAR(10));
CHAR pads on storage; trailing spaces are ignored in equality ('a' = 'a ' is true), and ANSI_PADDING is effectively always ON in modern versions.
CREATE TABLE t (c CHAR(10), v VARCHAR(10));
CHAR(n) (bpchar) stores and displays the padding, but treats trailing spaces as insignificant: they vanish when the value is cast to text or concatenated, and comparisons ignore them. TEXT or VARCHAR is the idiomatic choice; CHAR is not faster.
CREATE TABLE t (c CHAR(10), v VARCHAR(10));
CHAR pads on disk and strips trailing spaces on retrieval. VARCHAR keeps them, and whether 'a ' = 'a' depends on the collation: MySQL 8's default utf8mb4_0900_ai_ci is NO PAD, so they differ, while PAD SPACE collations such as utf8mb4_general_ci ignore trailing spaces.
CREATE TABLE t (c TEXT, v TEXT);
CHAR(n)/VARCHAR(n) are just TEXT affinity: no padding, no stripping, declared lengths ignored. Any length rule lives in a CHECK constraint.
CREATE TABLE t (c CHAR(10), v VARCHAR2(10));
CHAR(10) pads. CHAR against CHAR or a literal uses blank-padded comparison, so c = 'a ' is true, but CHAR against a VARCHAR2 column does not pad, so c = v is false when both hold 'a'. Use VARCHAR2 for real strings.
Rarely. Fixed-length codes such as a two-letter country code are the textbook case, and even there VARCHAR(2) stores the same data without the padding rules.
SQL Server and PostgreSQL ignore trailing spaces when comparing character values. Oracle does when both sides are CHAR or literals, but not CHAR against VARCHAR2. MySQL does only under PAD SPACE collations, and SQLite never does (the default BINARY collation compares bytes).
Overlength values error (or truncate, depending on mode) just as with VARCHAR. Shorter values are padded to n on storage, so SQL Server, PostgreSQL and Oracle return 'a' plus nine spaces from a CHAR(10) column; MySQL strips them on the way out.
In Oracle, '' IS NULL is true. Everywhere else it is false. That one fact rewrites your WHERE clauses.
Where the UUID can be a real type, and where it is 16 bytes wearing a costume.
The same four bytes, four spellings, and the SQL Server form is not even quoted.
SQLly is a native SQL workbench for macOS, Windows and Linux. Its formatter and plan viewer work in all five dialects.