Altering Table Structure and Definition | SQL Fundamentals | Teradata Vantage - Altering Table Structure and Definition - Advanced SQL Engine - Teradata Database

SQL Fundamentals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
zwv1557098532464.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1141
lifecycle
previous
Product Category
Teradata Vantage™

You may need to change the structure or definition of an existing table or temporary table. In many cases, you can use ALTER TABLE and RENAME to make the changes. Some changes, however, may require you to use CREATE TABLE to recreate the table.

You cannot use ALTER TABLE on an error logging table.

Making Changes to a Table

Use the RENAME TABLE statement to change the name of a table, temporary table, queue table, or error logging table.

Use the ALTER TABLE statement to perform any of the following functions:
  • Add or drop columns on an existing table or temporary table
  • Add column default control, FORMAT, and TITLE attributes on an existing table or temporary table
  • Add or remove journaling options on an existing table or temporary table
  • Add or remove the FALLBACK option on an existing table or temporary table
  • Change the DATABLOCKSIZE or percent FREESPACE on an existing table or temporary table
  • Add or drop column and table level constraints on an existing table or temporary table
  • Change the LOG and ON COMMIT options for a global temporary table
  • Modify referential constraints
  • Change the properties of the primary index for a table (some cases require an empty table)
  • Change the partitioning properties of the primary index for a table, including modifications to the partitioning expression defined for use by a partitioned primary index (some cases require an empty table)
  • Regenerate table headers and optionally validate and correct the partitioning of PPI table rows
  • Define, modify, or delete the COMPRESS attribute for an existing column
  • Add the BLOCKCOMPRESSION option used to modify the temperature-based Block Level Compression (BLC) for a table.
  • Change column attributes (that do not affect stored data) on an existing table or temporary table

Restrictions apply to many of the preceding modifications.

To perform any of the following functions, use CREATE TABLE to recreate the table:
  • Redefine the primary index or its partitioning for a non-empty table when not allowed for ALTER TABLE
  • Change a data type attribute that affects existing data
  • Add a column that would exceed the maximum lifetime column count

Interactively, the SHOW TABLE statement can call up the current table definition, which can then be modified and resubmitted to create a new table.

If the stored data is not affected by incompatible data type changes, an INSERT... SELECT statement can be used to transfer data from the existing table to the new table.

Related Topics

For a complete list of rules and restrictions on using ALTER TABLE to change the structure or definition of an existing table, see Teradata Vantage™ - SQL Data Definition Language Syntax and Examples, B035-1144.