Chapter 5: Character Data Types in SQL
Overview
SQL-89 defined A CHARACTER(n) or CHAR(n) data type, which represents a fixed-length string of ( n) printable characters, where ( n) is always greater than zero. Some implementations allow the string to contain control characters, but this is not the usual case. The allowable characters are usually drawn from ASCII or EBCDIC character sets and most often use those collation sequences for sorting.
SQL-92 added the VARYING CHARACTER(n) or VARCHAR(n), which was already present in many implementations. A VARCHAR(n) represents a string that varies in length from 1 to ( n) printable characters. This is important: SQL does not allow a string column of zero length, but you may find vendors whose products do allow it so that you can store an empty string.
SQL-92 also added NATIONAL CHARACTER(n) and NATIONAL VARYING CHARACTER(n) data types (or NCHAR(n) and NVARCHAR(n), respectively), which are made up of printable characters drawn from ISO-defined Unicode character sets. The literal values use the syntax N'
SQL-92 also allows the database administrator to define collation sequences and do other things with the character sets. A Consortium (www.unicode.org/) maintains the Unicode standards and makes them available in book form ( The Unicode Standard, Version 4.0.
Reading, MA: Addison-Wesley. 2003. ISBN 0-321-18578-1) or on the Web site.
5.1 Problems with SQL Strings
Different programming...