Handouts - 03 (Create Table)
Handouts - 03 (Create Table)
Note: Follow Handouts & Material & Examples which are discussing in classes to get good knowledge on ETL Testing
Session-3
Topics covered in session:
1. Syntax for CREATE command
2. Storage Attributes (Compress)
3. Constraints in Database
4. Structure for creation of table
3. Column Definitions.
Here we need to define Column name, Data type, Data type length, Storage attributes and
Constraints. Column name, Data type, Data type length information will share in PDM
document which is prepared by Data modeler.
Storage Attributes: If you want to reduce table size in Teradata we need to compress data
in columns. For the purpose of applying compress we need to use keyword COMPRESS.
Syntax for Compress:
1.Compress – This syntax by default will compress Null values in columns
2. Compress Null – This syntax also will compress null values in column.
3. Compress (‘M’,’F’) – This syntax will compress values ‘M’,’F’ and null values.
Constraints: While creating a table if you want to define any condition on columns we
need to use constraints. In database we are having following constraints.
Primary Key, Foreign Key, Unique, Not null, Check
Primary Key: For the purpose of retrieving unique information from a table we
need to maintain one column as Primary key in table.
Properties of Primary Key:
- A Primary Key is required.
- A Primary Key value will not allow duplicates
UNIQUE: In particular columns if you don’t want to maintain duplicate records we need to
go for UNIQUE constraint.
- In Teradata, UNIQUE constraint will not allow duplicates and will not allow null values.
- In Oracle, UNIQUE constraint will not allow duplicates and but it will allow null values.
NOT NULL: In a particular column if you don’t want to allow any null values we need to go
for NOT NULL constraint.
CHECK: While inserting data in to column, if you want to allow records by depending on
particular condition we need to go for CHECK constraint.
5. Indexes: In Teradata every table should contain Primary Index, Primary Index is useful
for the purpose of distribution of data. We are having two types of PI’s those are UPI and
NUPI.