This page is part of the book SQL-99 Complete, Really, by Peter Gulutzan & Trudy Pelzer. The authors have graciously allowed us to reproduce the contents of the book here. Because the book is about the SQL-99 standard, the contents of this and other pages in the book may not directly apply to MariaDB. Use the navigation bar to navigate the book.

In SQL, a character string is any sequence of zero or more alphanumeric characters that belong to a given Character set. A Character set is a named character repertoire that includes a Form-of-use encoding scheme which defines how the repertoire's characters are encoded as numbers. The SQL Standard defines several standard Character sets that your DBMS must support. A character string value may be a <literal>, an <identifier>, the value of a parameter or a host language variable or the result of any expression or argument that evaluates to a character string. All character strings belong to some Character set and are governed by the rules of some Collation during comparisons. A Collation is a named collating sequence. Character strings that belong to the same Character set are compatible.

A character string has a length: a non-negative integer equal to the number of characters in the string. Characters in a character string are numbered (from left to right), beginning with 1. A Character string also has a coercibility attribute; this helps your DBMS determine which Collation to use for a comparison that doesn't provide an explicit COLLATE clause. The coercibility attribute can be either COERCIBLE, EXPLICIT, IMPLICIT or NO COLLATION. (A coercibility attribute of COERCIBLE, EXPLICIT or IMPLICIT means the string has a current default Collation. A coercibility attribute of NO COLLATION means the string does not have a current default Collation.) Character strings are stored in either of the six character string <data type>s: CHARACTER, CHARACTER VARYING, CHARACTER LARGE OBJECT, NATIONAL CHARACTER, NATIONAL CHARACTER VARYING or NATIONAL CHARACTER LARGE OBJECT.