Example: VARCHAR Data Type. The following statement creates a table that defines two VARCHAR columns: InfoKey and InfoData. CREATE TABLE InfoTable (InfoKey VARCHAR(10) NOT NULL ,InfoData VARCHAR(16384) ) UNIQUE PRIMARY INDEX ( InfoKey );
May 14, 2020 · VARCHAR: This data type in db2 is used to store VARIABLE-LENGTH character strings. Syntax: column-name VARCHAR(n) 'n' is positive integer which represents maximum length of bytes a column can store. It should be greater than 0 and less than 32740. Example: CREATE TABLE db2_varchars ( v VARCHAR(20) NOT NULL);
Example: VARCHAR Data Type. The following statement creates a table that defines two VARCHAR columns: InfoKey and InfoData. CREATE TABLE InfoTable (InfoKey VARCHAR(10) NOT NULL ,InfoData VARCHAR(16384) ) UNIQUE PRIMARY INDEX ( InfoKey );
That is not correct for DB2 UDB for LUW (I can't comment on DB2 z/OS and DB2 AS/400 internals). DB2 for LUW will, for each row, only allocate the two bytes length, a null indicator byte if required, and the space for the data. Cheers Serge Actually, default length of the length field in VARCHAR is 4 bytes. Jan