Presentation is loading. Please wait.

Presentation is loading. Please wait.

Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata RDBMS Concepts.

Similar presentations


Presentation on theme: "Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata RDBMS Concepts."— Presentation transcript:

1 Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata RDBMS Concepts

2 Objective Data Types Data Definition Language Data Manipulation Language Temporary Tables

3 Teradata Versus ANSI Compliant with SQL 92, SQL 98 and SQL 99 standards

4 Numeric Data types BYTEINT - 1 Byte. SMALLINT – 2 Bytes. INTEGER - 4 Bytes. DECIMAL (n, m) – Space required depends on Number of digits.  1 – 2 => 1 byte  3 – 4 => 2 bytes  5 – 9 => 4 bytes.  10 – 18 => 8 bytes. FLOAT – 8 bytes.

5 Date Data Types DATE – Stored as 4 byte integer using following formula: YYYMMDD = ((YYYY - 1900)) * 10000 + (MM * 100) + DD TIME - hh:mm:ss.ssssss. Stored in 6 bytes. TIMESTAMP - DATE + TIME – 10 Bytes. TIME WITH TIME ZONE  hh:mm:ss.ssssss +/-hh.h. Stored in 8 bytes. TIMESTAMP WITH TIME ZONE –  DATE + TIME + ZONE. Stored in 12 bytes.

6 Character Data Types CHARACTER VARCHAR LONG VARCHAR BYTE VARBYTE

7 Default Value Control Phrases COMPRESS NOT NULL DEFAULT BETWEEN n AND n (Range) CONSTRAINT CASESPECIFIC FORMAT TITLE

8 DDL CREATE TABLE  Table Kind clause  Table Options clause  Column Definition clause  Index Definition clause  Temporary/Volatile Table Preservation clause COLLECT STATISTICS ON table_name COLUMN column_name INDEX ( column_name ) INDEX index_name

9 Create Table CREATE TABLE Employee ( EmpNo SMALLINT CHECK (EmpNo >= 10001 AND EmpNo <= 32001) NOT NULL, Name VARCHAR(12) UPPERCASE NOT NULL, Salary DECIMAL(8,2) FORMAT ’ZZZ,ZZ9.99’ CHECK (Salary >= 1.00 AND Salary <= 999000.00), dob DATE FORMAT ’MMMbDDbYYYY’ NOT NULL, ) UNIQUE PRIMARY INDEX (EmpNo), INDEX (Name) ;

10 Views A View is a virtual table that appears as base table. Dynamic window on the underlying database. Constructed from one or more base tables (or views). View Definitions stored in the data dictionary.

11 Macros A frequently used SQL statement or series of statements can be incorporated into a macro and defined using the SQL CREATE MACRO statement. A macro can  include an EXECUTE statement that executes another macro.  contain a data definition statement only if it is the only SQL statement in that macro.  contain parameters that are substituted with data values each time the macro is executed. Teradata Database treats it as a single request. To drop a macro, use the DROP MACRO statement

12 Why we need macros? MACROS are typically used to reduce the number of characters that must be entered to specify an operation. Saving the user time. Decreasing the chance of making errors.

13 Stored Procedures Consist of a set of control and condition handling statements, that make SQL a computationally complete programming language. A single statement stored procedure body can contain one control statement,such as LOOP or WHILE, or one SQL DDL, DML, or DCL statement. Some statements are not allowed, including:  Any declaration (local variable, cursor, or condition handler) statement  A cursor statement (OPEN, FETCH, or CLOSE)

14 Stored Procedures A compound statement stored procedure body consists of a BEGIN-END statement enclosing a set of declarations and statements, including:  Local variable declarations  Cursor declarations  Condition handler declaration statements  Control statements  SQL DML, DDL, and DCL statements supported by stored procedures Compound statements can also be nested.

15 User-Defined Functions User-defined functions (UDFs) allow you to extend SQL by writing your own functions in the C programming language, installing them on the database, and then using them like standard SQL functions. You can also install UDF objects or packages from third- party vendors, without providing the source code. UDFs run in parallel, as required, on all AMPs. Scalar functions take input parameters and return a single value result. Aggregate functions produce summary results. They differ from scalar functions in that they take grouped sets of relational data, make a pass over each group, and return one result for the group.

16 Space Terminology Permanent Space ( Perm Space)  Maximum amount of space available for table and index Spool Space  Max amount of space available for requests Temp Space  Used for temporary tables

17 Database Space DBC SYSADMINCRASHDUMPSSYSTEMFE

18 Database Space Initially system user DBC owns all available space. Database Hierarchy – Owner, Parent, Children. When you create a new user it acquires space from its immediate parent. An user can transfer the ownership of the database to another user.

19 Temporary Tables Global TempTables Use Temp Space Globally Stored Definition Session Local Survive a System Restart Data Dictionary access Create Permission Required Up to 2000 tables Volatile Tables Use Spool Space Private Definition Session Local Don’t survive at system restart No Data Dictionary access Do not need any permissions Up to 1000 tables Derived Tables Uses Spool Space Statement Local Statement local Don’t survive at system restart No Data Dictionary access Do not need any permissions

20 Questions ?


Download ppt "Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata RDBMS Concepts."

Similar presentations


Ads by Google