Teradata Table Properties
- MULTISET Vs SET (All Teradata tables can be either SET or MULISET)
- SET tables does not allow two rows in the table to be exactly same.
- MULTISET tables allow two or more rows in the table to be exactly same.
- By default, SET table created in TERADATA mode but MULTISET table is created in ANSI mode.
- It is advisable to define a table as MULTISET and define the UPI for uniqueness of entries in the table in order to
avoid an extra check for uniqueness of each and every column entry of a row by the system.
- FALLBACK ( Data Protection)
- JOURNAL (Permanent Journal : Data Recovery)
- Used for recovery from unexpected hardware or software disasters.
- May be specified for:
- One or more tables
- One or more databases
- Permits capture of before images for database rollback.
- Permits capture of after images for database rollforward.
- Permits archiving change images during table maintenance.
- Reduces need for full-table backups.
- Provides a means of recovering NO FALLBACK tables.
- Requires additional disk space for change images.
- Requires user intervention for archive and recovery activity.
Before Journal: Captures image of the table before the transaction.
- NO BEFORE JOURNAL
- DUAL BEFORE JOURNAL
-> If the JOURNAL keyword is specified without NO or DUAL, then a single copy of the image is maintained unless FALLBACK is in effect or is also specified.
-> If journaling is requested for a table that uses fallback protection, DUAL images are maintained automatically.
After Journal: Captures image of the table after the transaction.
- NO AFTER JOURNAL
- DUAL AFTER JOURNAL
- LOCAL AFTER JOURNAL
- NOT LOCAL AFTER JOURNAL
-> The NO and DUAL options specify the number of after-change images to be maintained for the table.
-> NOT LOCAL and LOCAL specify whether single after-image journal rows for non-fallback data tables are written
on the same virtual AMP (LOCAL) as the changed data rows, or on another virtual AMP in the cluster (NOT LOCAL).
Syntax: Change the journalising option of a table.
ALTER TABLE [databasename].[tablename], BEFORE JOURNAL;
ALTER TABLE [databasename].[tablename], DUAL AFTER JOURNAL;
- CHECKSUM (Disk I/O Integrity Checking)
- The Teradata Database permits you to select various levels of disk I/O integrity checking of your table data
using one of the following integrity checks ranked in order of their ability to detect errors:
- Full end-to-end checksums (ALL) : Detects most bit, byte, and byte string errors.
- Statistically sampled partial end-to-end checksums (LOW, MEDIUM, HIGH) :
Detects lost writes and intermediate levels of bit, byte, and byte string errors.
HIGH, MEDIUM, LOW checksum settings are deprecated and are equivalent to specifying ON.
- Disable checksum disk I/O integrity checks (NONE) :
Detects some forms of lost writes using standard file system metadata verification.
- The checksum setting applies to primary data rows, fallback data rows, and all secondary index rows for the table.
- This feature detects and logs disk I/O errors: it does not fix them.
- The more words used to generate the checksum value, the better able that checksum is to detect disk I/O errors.
Because CPU utilization increases as a function of the number of words used to generate a checksum,
several different levels of checking are provided so you can adjust disk I/O integrity checking at
the level of individual tables as needed, balancing integrity checking against system performance.
Syntax: Change the integrity checking level
ALTER TABLE [databasename].[tablename], CHECKSUM = HIGH IMMEDIATE;
- LOG/NO LOG (The transaction journaling option for a global temporary table)
- LOG maintains a transaction journal for the temporary table during the time is materialized.
- NO LOG specifies that no transaction journal is to be kept.
- You cannot change the LOG/NO LOG properties of a global temporary table if any materialized instances of the table
exist anywhere in the Teradata Database.
- ON COMMIT DELETE ROWS/PRESERVE ROWS
- The action to take with the contents of a global temporary table when a transaction ends.
- DELETE ROWS clears the temporary table of all rows.
- PRESERVE ROWS retains the rows in the table after the transaction is committed.
- You cannot change the ON COMMIT properties of a global temporary table if any materialized instance of the table
exists anywhere in the Teradata Database.
Syntax/Example 1: Permanent MULTISET table with properties
CREATE MULTISET TABLE [databasename].[tablename],
NO FALLBACK,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT
(
col_1 INTEGER,
col_2 VARCHAR(50) CHARACTER SET LATIN CASESPECIFIC TITLE 'Column Name 2'
)
PRIMARY INDEX ( col_1 ,col_2 );
Syntax/Example 2: Permanent SET table with properties
CREATE SET TABLE [databasename].[tablename],
FALLBACK,
BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT
(
col_1 INTEGER,
col_2 VARCHAR(50) CHARACTER SET LATIN CASESPECIFIC TITLE 'Column Name 2'
)
PRIMARY INDEX ( col_1 ,col_2 );
Syntax/Example 3: Temporary MULTISET table with properties
CREATE MULTISET GLOBAL TEMPORARY TABLE [databasename].[tablename],
LOG
(
col_1 INTEGER,
col_2 VARCHAR(50) CHARACTER SET LATIN CASESPECIFIC TITLE 'Column Name 2'
)
PRIMARY INDEX ( col_1 ,col_2 )
ON COMMIT PRESERVE ROWS;
Syntax/Example 4: Temporary SET table with properties
CREATE SET GLOBAL TEMPORARY TABLE [databasename].[tablename],
LOG
(
col_1 INTEGER,
col_2 VARCHAR(50) CHARACTER SET LATIN CASESPECIFIC TITLE 'Column Name 2'
)
PRIMARY INDEX ( col_1 ,col_2 )
ON COMMIT DELETE ROWS;