0% found this document useful (0 votes)
16 views2 pages

Handouts - 03 (Create Table)

The document discusses creating tables in Teradata including syntax for the CREATE command, storage attributes like compression, and constraints like primary keys, foreign keys, unique constraints, and check constraints.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Handouts - 03 (Create Table)

The document discusses creating tables in Teradata including syntax for the CREATE command, storage attributes like compression, and constraints like primary keys, foreign keys, unique constraints, and check constraints.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Quality Thought ETL Testing Daily Handouts

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

1. Syntax for CREATE Command:


1. Create Set/Multiset Table Tablename
In Teradata we are having two types of tables, those are Set and MultiSet.
Absolute Duplicates: If complete row in a table is having duplicate records such kind of
records we can call it as Absolute duplicates.
Set table: In a particular table if you don’t want to allow absolute duplicates we need to
create that table as Set table
Multiset Table: In a particular table if you want to allow absolute duplicates we need to
create that table as Multiset table.
If you not define either Set or Multiset then by default that table will be created as Set table.

2. Table options (Fallback, Journal)


To provide protection to table we need to define Table options using keywords Fallback,
Journal

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

QUALITY THOUGHT * www.facebook.com/qthought * www.qualitythought.in


PH NO: 9963486280, 040-40025423 EMAIL ID: [email protected]
Note: Follow Handouts & Material & Examples which are discussing in classes to get good knowledge on ETL Testing
Quality Thought ETL Testing Daily Handouts

- The Primary Key value cannot be NULL.


- The Primary Key value should not be changed.
- The Primary Key column should not be changed.
- In a table we can maintain only one primary key.
A Primary Key may be any number of columns, such kind of primary keys we can
call it as Composite Primary Key.

Foreign Key: For the purpose of maintaining relationship between multiple


tables in database we need to maintain Foreign keys.
Rule: Each Foreign Key must exist as a Primary Key in a related table.
- Foreign Keys are optional.
- A Foreign Key can contain duplicates.
- The Foreign Key value many be NULL.
- The Foreign Key value may be changed.
- A Foreign Key may be any number of columns.

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.

4. Final Structure for creation of table: Create a table as per requirement


Scenario 3: Create Set table emp
(
E_Id integer Not Null Constraint P_K Primary Key,
E_Name varchar(10) Not Null,
Sal Integer Constraint Ch_k Check(Sal>1000),
Mobile_Number Integer Not Null Constraint U_K Unique,
D_Id Integer constraint F_K References Dep(Did), X_Id Integer,
Gender Char(1) Compress(‘M’,’F’) )

QUALITY THOUGHT * www.facebook.com/qthought * www.qualitythought.in


PH NO: 9963486280, 040-40025423 EMAIL ID: [email protected]

You might also like