15.10 - Example: Adding and Changing Algorithmic Compression - Teradata Database

Teradata Database SQL Data Definition Language Syntax and Examples

prodname
Teradata Database
vrm_release
15.10
created_date
December 2015
category
Programming Reference
featnum
B035-1144-151K

These examples use the following table definition.

     CREATE TABLE Pendants (
       col_1 INTEGER, 
       col_2 CHARACTER (10));

This example adds column c3, which specifies algorithmic compression, to table Pendants.

     ALTER TABLE Pendants 
     ADD col_3 CHARACTER(30) COMPRESS USING compress_udf 
                             DECOMPRESS USING decompress_udf;

This example adds column c3, which specifies algorithmic and multivalue compression, to table Pendants.

     ALTER TABLE Pendants 
     ADD col_3 CHARACTER(30) COMPRESS ('amethyst', 'amber')
                             COMPRESS USING compress_udf 
                             DECOMPRESS USING decompress_udf;

This example changes the definition of Pendants.col_2 to add algorithmic compression. Because Pendants is empty, this ALTER TABLE request completes without error.

     ALTER TABLE Pendants 
     ADD col_2 CHARACTER(10) COMPRESS 
                             COMPRESS USING compress_udf 
                             DECOMPRESS USING decompress_udf;

This example is the same as the previous example except that a row has been added to Pendants. Because Pendants is not empty, the system returns an error to the requestor.

     INSERT INTO Pendants(1, 'amber');
     ALTER TABLE Pendants 
     ADD col_2 CHARACTER(10) COMPRESS 
                             COMPRESS USING compress_udf 
                             DECOMPRESS USING decompress_udf;