VARCHAR data type
VARCHAR()
is a length constrained string data type.
Syntax
VARCHAR({<length> | max})
Arguments
Argument | Description |
---|---|
<length> | integer value representing the number of characters allowed in the string |
max | Allow a maximum of 256mb |
Additional information
- The
Data overflow
error is generated if a VARCHAR value excedes the<length>
constraint
Examples
CREATE TABLE with VARCHAR
CREATE TABLE doctest (_id ID, limited VARCHAR(21), unlimited VARCHAR(max));
INSERT INTO doctest (_id, limited, unlimited)
VALUES (1, 'A 21 character string', 'Varchar max does not limit the number of characters allowed.');
INSERT INTO doctest (_id, limited)
VALUES (2, 'This string will cause a data overflow');