SQL String and Character Types

String Type

Name Description Syntax
STRING A NuoDB extension. NuoDB handles string types as potentially unlimited in length. NuoDB recommends that you use String types instead of Character types. There is no storage penalty for using STRING, so most application developers should use STRING rather than CHAR or VARCHAR. For VARCHAR character types, NuoDB checks and supports the defined length.
Characters are all stored in UTF-8.
An empty string or a string containing only spaces and assigned to a numeric value becomes zero.
STRING

Character Types

Name Description Alias[es] Syntax
CHARACTER variable-length character string CHAR
CHARACTER VARYING (n)
VARCHAR (n)
CHARACTER (n)
CHARACTER LARGE OBJECT unlimited character length CHAR LARGE OBJECT

CLOB

NCHAR LARGE OBJECT

NCLOB

TEXT
CHARACTER LARGE OBJECT
NATIONAL CHARACTER specifies predefined national character set, synonymous with char.

NATIONAL CHAR(n)
NCHAR(n)
NATIONAL CHARACTER VARYING(n)
NATIONAL CHAR VARYING(n)

NATIONAL CHARACTER (n)
TEXT unlimited character length CLOB TEXT

Note: For character varying data types, if n equals 0, the default length is 1.

Note: Strings are stored within the entire data record for a row. CLOBs are stored in separate atomThe internal object structure representing all data in a NuoDB database. Atoms are self-coordinating objects that represent specific types of information (such as data, indexes or schemas).s. CLOBs are not versioned. So there is only one version at any one time for a CLOB field in a record. Strings have multiple versions tracking any changes to that particular field in a record. CLOBs are intended for large objects. Strings, while they have no fixed length, are not intended for large objects.

String Input

String literals are specified as single quoted strings. Example:

SQL> CREATE TABLE tbl(x STRING);
SQL> INSERT INTO tbl VALUES ('abc');
SQL> SELECT * FROM tbl; X --- abc

For SQL Server compatibility, string literals may be represented as N'string' as in this example:

SQL> INSERT INTO tbl VALUES (N'def');
SQL> SELECT * FROM tbl; X --- abc def

This allows the input of Unicode characters which would otherwise have been allowed within the quoted string anyways. It is not necessary to precede a string with Unicode characters with the N prefix.