Represents a large character string. A character large object (CLOB) column can store character data, such as simple text or HTML.
Note: A CLOB column can store XML or JSON documents; however, Teradata recommends that you use the Teradata XML and Teradata JSON data types for that purpose.
where:
Syntax element … |
Specifies … |
n |
the number of characters to allocate for the CLOB column. The maximum value depends on the server character set: If a value for n is not specified, the default is the maximum value. |
K |
that the number of characters to allocate for the CLOB column is nK, where K = 1024 and the maximum value for n is as follows: |
M |
that the number of characters to allocate for the CLOB column is nM, where M = 1024K and the maximum value for n is as follows: |
G |
that 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: 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 SQL Data Definition Language. Also see “CHARACTER SET Phrase” on page 226. |
attribute |
appropriate data type, column storage, or column constraint attributes. A CLOB column supports the following attributes: For more information about the NOT NULL attribute, see Chapter 11: “Default Value Control Phrases”. For more information about the FORMAT and TITLE attributes, see Chapter 12: “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.
The CHARACTER SET clause can specify the following server character sets for a CLOB column:
The following are some functions and operators that support CLOB types:
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.
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 |
SQL Functions, Operators, Expressions, and Predicates. |
implementing UDFs and external stored procedures that operate on CLOB types |
SQL External Routine Programming. |
implementing stored procedures that use CLOB local variables or parameters |
|