Represents a large character string. A character large object (CLOB) column can store character data, such as simple text or HTML.
- The number of characters to allocate for the CLOB column. The maximum value depends on the server character set:
- For the LATIN server character set, n cannot exceed 2097088000.
- For the UNICODE server character set, n cannot exceed 1048544000.
- If a value for n is not specified, the default is the maximum value.
- The number of characters to allocate for the CLOB column is nK, where K = 1024 and the maximum value for n is as follows:
- For the LATIN server character set, n cannot exceed 2047937.
- For the UNICODE server character set, n cannot exceed 1023968.
- The number of characters to allocate for the CLOB column is nM, where M = 1024K and the maximum value for n is as follows:
- For the LATIN server character set, n cannot exceed 1999.
- For the UNICODE server character set, n cannot exceed 999.
- The number of characters to allocate for the CLOB column is nG, where G = 1024M. When G is specified, n must be 1 and the server character set must be LATIN.
- CHARACTER SET
- The server character set for the CLOB column being defined:
- The LATIN server character set represents fixed 8-bit characters from the ASCII ISO 8859 Latin1 or ISO 8859 Latin9 repertoires.
- The UNICODE server character set represents fixed 16-bit or 32-bit characters from the Unicode® standard.
- If the CHARACTER SET clause is omitted, the default server character set depends on how the user is defined in the DEFAULT CHARACTER SET clause of the CREATE USER statement. For details, see “CREATE USER” in Teradata Vantage™ SQL Data Definition Language Syntax and Examples, B035-1144.
- Also see CHARACTER SET Phrase.
- Appropriate data type, column storage, or column constraint attributes.
- A CLOB column supports the following attributes:
- NOT NULL
- For more information about the NOT NULL attribute, see Default Value Control Phrases.
- For more information about the FORMAT and TITLE attributes, see Data Type Formats and Format Phrases.
CLOB is ANSI SQL:2011 compliant.
Whenever a client application talks to Teradata Database, it indicates its character set (form-of-use for character data). Teradata Database returns all character data to the application in that form.
Whenever multibyte characters are involved, their representation has the length (n-2)/2 multibyte characters exclusive of the preceding Shift-Out and following Shift-In characters.
The following table lists the client representations for the CLOB data type. Determining the application definitions and client data types is the responsibility of the application programmer.
Define the length of the CLOB string as k, where 0 ≤ k ≤ n.
|Client CPU Architecture||Client Internal Data Format|
|IBM mainframe||Eight byte (most significant byte first) length count k followed by k bytes of EBCDIC character data for a total of k+8 bytes.|
||Eight byte (most significant byte first) length count k followed by k bytes of ASCII character data for a total of k+8 bytes.|
|Intel||Eight byte (least significant byte first) length count k followed by k bytes of ASCII character data for a total of k+8 bytes.|
A table can have a maximum of 32 LOB columns.
Queue tables cannot have CLOB columns.
A LOB column cannot be a component of an index. Because of this restriction, a table must define at least one non-LOB column.
Functions That Operate on CLOBs
- TRANSLATE and TRANSLATE_CHK
- Concatenation operator (||)
- Explicit data type conversion (CAST and Teradata conversion syntax)
- User-defined functions (UDFs)
- Stored procedures
- External stored procedures
Example: CLOB Data Type
The following example creates a table that defines a CLOB column named clarge:
CREATE TABLE t1 (id INTEGER ,clarge CLOB(2K) CHARACTER SET UNICODE);
Teradata Database stores the character data using the UNICODE server character set.
Example: Inserting CLOB Data
The following example shows a stored procedure that inserts part of a CLOB into one table and the remaining part of the CLOB into another table:
CREATE TABLE LocalData(ld_ID INTEGER, ld_DATA CLOB); CREATE TABLE GlobalData (gd_ID INTEGER, gd_DATA CLOB); CREATE PROCEDURE DataSplitter(IN local_ID INTEGER, IN global_ID INTEGER, IN all_DATA CLOB) BEGIN INSERT LocalData (local_ID, SUBSTRING(all_DATA FROM 1 FOR 128546)); INSERT GlobalData (global_ID, SUBSTRING(all_DATA FROM 128547)); END;
|FOR information on …||SEE …|
|on functions and operators that support CLOB types||Teradata Vantage™ SQL Functions, Expressions, and Predicates, B035-1145.|
|implementing UDFs and external stored procedures that operate on CLOB types||Teradata Vantage™ SQL External Routine Programming , B035-1147 .|
|implementing stored procedures that use CLOB local variables or parameters||