Documente Academic
Documente Profesional
Documente Cultură
A Teradata Database
A Teradata database is a defined logical repository for:
Tables
Views
Macros
Triggers
Stored Procedures
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:
Database
Unique Name
Password = Value
Define and use Perm space
Define and use Spool space
Define and use Temporary space
Set Fallback protection default
Set Permanent Journal defaults
Multiple Account strings
Logon and establish a session with a priority
May have a startup string
Default database, dateform, timezone,
and default character set
Collation Sequence
Unique Name
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 or stored procedures.
User DBC
No Perm Space
User SYSDBA
User_A
Database_1
Database_2
User D
Database_3
User_B
User_C
CrashDumps
QCD
SysAdmin
SysDBA
SystemFE
Customer_Service
A User and/or a
Database may be given
PERM space.
In this example, Mark
and Tom have no
PERM space, but
Susan does.
Sys_Calendar
CS_Users
Mark
Tom
Susan
CS_View_Mac
CS_Tables
View_1
View_2
Table_1
Table_2
Table_3
Table_4
Macro_1
Macro_2
Permanent Space
CREATE DATABASE CS_tables FROM Customer_Service
AS PERMANENT = 80e9 BYTES, ...
AMP
Perm Space
Limit per AMP
AMP
AMP
AMP
AMP
AMP
AMP
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 owners 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
CREATE USER Susan FROM CS_Users AS PERMANENT = 40e6 BYTES,
SPOOL = 240e6 BYTES, PASSWORD = secret
AMP
Spool Space
Limit per AMP
AMP
AMP
AMP
AMP
AMP
AMP
AMP
30 MB 30 MB 30 MB 30 MB 30 MB 30 MB 30 MB 30 MB
Insufficient Spool errors often result from poorly distributed data or joins
on columns with large numbers of non-unique values.
Keeping Spool rows small and few in number reduces Spool I/O.
Temporary Space
CREATE USER Susan FROM CS_Users AS PERMANENT = 40e6 BYTES,
SPOOL = 240e6 BYTES, TEMPORARY = 120e6 BYTES, PASSWORD = secret
AMP
Temporary
Space Limit
per AMP
AMP
AMP
AMP
AMP
AMP
AMP
AMP
15 MB 15 MB 15 MB 15 MB 15 MB 15 MB 15 MB 15 MB
The Temporary limit cannot exceed the Temporary limit of the original owner.
The Temporary limit is divided by the number of AMPS in the system, giving a
per-AMP limit that cannot be exceeded.
Note: Volatile Temporary tables and derived tables utilize Spool space.
username
current database
ACCOUNT account id
SESSION session #
Example 1:
SELECT
USER, ACCOUNT,
SESSION, DATABASE;
User
SUSAN
Account
$M_9038
Session
1000
Database
SUSAN
DATABASE Order_DB;
SELECT USER, ACCOUNT,
SESSION, DATABASE;
User
SUSAN
Account
$M_9038
Session
1000
Database
Order_DB
Table/View/Macro Name
customer
cust_orders
TableKind
T
V
Comment
?
?
cust_ord_ix
orders
orders_hash_1
orders_ix_cust_id
set_ansidate_on
I
T
N
I
M
?
?
?
?
?
Example 2:
HELP USER Order_DB;
Creating Tables
Creating a table requires ...
defining columns
assigning of a primary index
optional assignment of secondary indexes
CREATE TABLE Employee
(Employee_Number
,Last_Name
,First_Name
,Salary_Amount
,Department_Number
,Job_Code
Primary
Secondary
CREATE
DROP
CREATE
DROP
Tables
Views
Macros
Triggers
Procedures
Data Types
TYPE
Name
Date/Time DATE
TIME (WITH ZONE)
Numeric
Byte
Character
Bytes
Description
YYYYMMDD
6/8
HHMMSSZZ
10 / 12
YYYYMMDDHHMMSSZZ
DECIMAL (18,18)
2, 4, 8
+ OR -
NUMERIC (18,18)
2, 4, 8
+ or -
BYTEINT
-128 to +127
SMALLINT
-32,768 to +32,767
INTEGER
-2,147,483,648 to +2,147,483,647
FLOAT
IEEE floating pt
BYTE(n)
0 - 64,000
VARBYTE (n)
0 - 64,000
CHAR (n)
0 - 64,000
VARCHAR (n)
0 - 64,000
LONG VARCHAR
GRAPHIC
0 - 32,000
VARGRAPHIC
0 - 32,000
LONG VARGRAPHIC
same as VARGRAPHIC(32,000)
A Sample Scenario
Object
Database and/or User
Table and/or View
Macro and/or Trigger
Stored Procedure
Role and/or Profile
Table
View
EXECUTE
Database
Table
Journal
GRANT
REVOKE
Privileges on
Databases
Users
Objects
D
B
A
P
R
O
G
R
A
M
M
E
R
S
U
S
E
R
ADMIN
O
P
E
R
Review Questions
True or False
____ 1. A database will always have tables.
____ 2. A user will always have a password.
____ 3. A user creating a subordinate user must give up some of his/her Perm Space.
____ 4. Creating tables requires the definition of at least 1 column and the user assignment of a
Primary Index.
____ 5. The sum of all user and database Perm Space will equal the total space on the system.
____ 6. The sum of all user and database Spool Space will equal the total space on the system.
____ 7. Before a user can read a table, a table SELECT privilege must exist in the DD/D for that user.
____ 8. Deleting a macro from a database reclaims Perm Space for the database.
9. Which of the following is FALSE about PERM space? ____
a.
b.
c.
d.
1.
True
2.
False
3.
A user creating a subordinate user must give up some of his/her Perm Space.
False
4.
Creating tables requires the definition of at least 1 column and the user
assignment of a Primary Index.
True
5.
system.
The sum of all user and database Perm Space will equal the total space on the
False
6.
system.
The sum of all user and database Spool Space will equal the total space on the
True
7.
that user.
Before a user can read a table, a table SELECT privilege must exist in the DD/D for
False
8.
Deleting a macro from a database reclaims Perm Space for the database.