Module 6: Creating A Teradata Database
Module 6: Creating A Teradata Database
Notes:
"Database_2" is owned by "Sysdba".
A database is empty until objects are created within it.
A Teradata User
A Teradata user is a database with an assigned password.
A Teradata user may logon to Teradata and access objects within:
• itself
• other databases for which it has access rights
Examples of attributes that may be specified for a user:
• Perm Space – maximum amount of space available for tables
• Spool Space – maximum amount of work space available for requests
• Temp Space – maximum amount of temporary table space
A user is an active repository while a database is a passive repository.
A user is created with the CREATE USER command.
• You can only LOGON as a known User to establish a session with Teradata.
• Tables and Stored Procedures require Perm Space.
• Views, Macros, and Triggers are definitions in the DD/D and require no Perm Space.
• A database (or user) with zero Perm Space may have views, macros, and triggers, but
cannot have tables, stored procedures, or user-defined functions.
Hierarchy of Databases and Users
Maximum Perm Space - available
but not yet assigned
User DBC Current Perm Space - contains
tables or stored procedures
No Box No Perm Space
User SYSDBA
User_A User D
Database_1 Database_2 Database_3
User_B User_C
Perm Space
Limit per AMP 10 GB 10 GB 10 GB 10 GB 10 GB 10 GB 10 GB 10 GB
• Table rows, index subtable rows, and stored procedures row use Perm space.
• Fallback protection uses twice the Perm space of No Fallback?.
• Perm space is deducted from the owner’s database space.
• Disk space is not reserved ahead of time, but is available on demand.
• Perm space is defined globally for a database.
• Perm space can be dynamically modified.
• The (global limit)? divided by the number of AMPs is the per/AMP limit.
• The per/AMP limit cannot be exceeded.
• Good data distribution is crucial to space management.
Spool Space
Spool Space
Limit per AMP 30 MB 30 MB 30 MB 30 MB 30 MB 30 MB 30 MB 30 MB
Temporary
Space Limit
per AMP
15 MB 15 MB 15 MB 15 MB 15 MB 15 MB 15 MB 15 MB
• Note: Volatile Temporary tables and derived tables utilize Spool space.
Creating Tables
Creating a table requires ...
– defining columns
– assignment of a primary index (either by user or Teradata)
– optional assignment of secondary indexes
CREATE TABLE Employee
(Employee_Number INTEGER NOT NULL
,Last_Name CHAR(20) NOT NULL
,First_Name VARCHAR(20)
,Salary_Amount DECIMAL(10,2)
,Department_Number SMALLINT
,Job_Code CHAR(3))
Primary UNIQUE PRIMARY INDEX (Employee_Number)
Secondary INDEX (Last_Name) ;
Tables
Database objects may be created or CREATE Views
dropped as needed. Macros
DROP
Triggers
Procedures
Secondary indexes may be
– created at table creation
CREATE
– created after table creation INDEX (secondary only)
– dropped after table creation DROP
Data Types
TYPE Name Bytes Description