Introduction to Teradata Client Tools. 2 Introduction to Teradata SQL  OBJECTIVES...

download Introduction to Teradata Client Tools. 2 Introduction to Teradata SQL  OBJECTIVES : ïƒ Teradata Product Components. ïƒ Accessing Teradata – Database

of 31

  • date post

    18-Jan-2018
  • Category

    Documents

  • view

    244
  • download

    3

Embed Size (px)

description

3 Teradata Database 12.0 Product Components

Transcript of Introduction to Teradata Client Tools. 2 Introduction to Teradata SQL  OBJECTIVES...

Introduction to Teradata Client Tools 2 Introduction to Teradata SQL OBJECTIVES : Teradata Product Components. Accessing Teradata Database / User Teradata SQL Assistant Teradata Administrator 3 Teradata Database 12.0 Product Components 4 Teradata User/Database Organization To ensure space will always be available for spool... DBC Spool_Reserve SystemFE SysAdmin CrashDumps Sys_Calendar Users View, Macro, and Stored Procedure Databases Database (1) Database (1) Database (1) Database (2) QCD SYSDBA Temporary Table Databases CREATE DATABASE Spool_Reserve AS PERM = spool_amount ; (The space used by Spool_Reserve will reduce the total available permanent space in the system by 20% to 25%.) 5 Users and Databases Human_ResourcesAccounting DBC SYSDBA PR01PR02PR03BF01BF02BF03 Personnel Benefits You can grant CREATE DATABASE authority to any user. The user may then create other users and databases from: The users own space, or The space of another user or database (if authorized). 6 Start Teradata Service Run the Service Teradata Database Initiator By Default this service is Manual in Demo. You may need more Services to start based on the tools to explore. This applies only for Demo CD 7 Teradata SQL Assistant 8 Open the Teradata SQL Assistant. This is the interface to work with the Teradata SQL 9 Connect to Database 10 Configure Database Connection By Default the Demo installation configures DemoTDAT as ODBC connection. Password can be saved in the connection as below. If left blank, it prompts on logon. In real-time situation the Server info includes the Server IP address. Nodes IPs in case of MPP. DBC is a super user and default password is DBC Leave the user/password blank. 11 SQL Assistant Different Windows Explain each Window Database Explorer Tree, Query Window, Answer Set Window, History Window 12 Try this out Where is my DUAL SELECT 100*2; SELECT DATE; SELECT 10/3.000; Explore help user dbc; select * from users; help user financial; select * from Financial.accts; show table Financial.accts; help table Financial.accts; 13 SQL Assistant Tools - Options 14 Default Database Setting the Default Database As a valid user, you will normally have access rights to your own user database and the objects it contains. You may also have permission to access objects in other databases. The user name you logon with is usually your default database. (This depends on how you were created as a user.) Select Database; --- Gives the Current Database Changing the Default Database The DATABASE command is used to change your default database. For example: DATABASE Financial; sets your default database to Financial. Subsequent queries (assuming the proper privileges are held) are made against the Financial database. 15 HELP Commands: Database objects The HELP Command is used to display information about database objects such as (but not limited to): Databases and Users Tables Views Macros HELP retrieves information about these objects from the Data Dictionary. Below are the syntactical options for various forms of the HELP command: HELP Command HELP DATABASE databasename; HELP USER username; HELP TABLE tablename; HELP VIEW viewname; HELP MACRO macroname; HELP COLUMN table or viewname.*; (all columns) HELP COLUMN table or viewname.colname..., colname; HELP INDEX tablename; HELP STATISTICS tablename; HELP CONSTRAINT constraintname; HELP JOIN INDEX join_indexname; HELP TRIGGER triggername; 16 Lets Create an User for Self Create a user for yourself. This user is used for all the exercises to be done during the training. CREATE USER TESTUSER FROM DBC AS PASSWORD=TESTUSER PERM= SPOOL= TEMPORARY = DEFAULT DATABASE = TESTUSER ; GRANT SELECT ON DBC TO TESTUSER; Log off & log on using TESTUSER 17 Teradata SQL Extensions Here is a list of Teradata extensions ADD_MONTHS BEGIN/ END TRANSACTION COLLECT/ DROP STATISTICS COMMENT ON CONCATENATION EXPLAIN FALLBACK FORMAT HELP INDEX LOCKING MACRO Facility CREATE REPLACE DROP EXECUTE NULLIFZERO/ZEROIFNULL NAMED SUBSTR SHOW TRIM TITLE WITH WITH... BY 18 Session Mode Teradata / ANSI Teradata is ANSI Compliant. SQL Assistant can be run on Teradata & ANSI modes. Default options are different for Teradata & ANSI modes Session mode can be changed using options while defining the Teradata ODBC connection 19 The HELP DATABASE Command The HELP DATABASE command shows all objects in the database specified. HELP DATABASE FINANCIAL; Table/View/Macro nameKind accts T checking_acct T checking_tran T credit_acct T credit_tran T customer T Objects may be recognized by their 'Kind' designation as follows: Table= T View = V Macro= M Trigger= G Join Index= J Stored Procedure= P The '?' is how BTEQ displays a null, indicating that no user comments have been entered. Similarly other HELP functions can be used. 20 The SHOW Command The SHOW command displays the current Data Definition Language (DDL) of a database object (e.g., Table, View, Macro, Trigger, Join Index or Stored Procedure). Sample Show Commands Command Return SHOW TABLE tablename; CREATE TABLE statement SHOW VIEW viewname; CREATE VIEW statement SHOW MACRO macroname; CREATE MACRO statement 21 The SHOW TABLE Command CREATE SET TABLE CUSTOMER_SERVICE.employee,FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL ( employee_number INTEGER, manager_employee_number INTEGER, department_number INTEGER, job_code INTEGER, last_name CHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL, first_name VARCHAR(30) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL, hire_date DATE NOT NULL, birthdate DATE NOT NULL, salary_amount DECIMAL(10,2) NOT NULL ) UNIQUE PRIMARY INDEX ( employee_number ); 22 Test Default Options Teradata Vs. ANSI Database Financial; CREATE TABLE TAB1 ( COL1 INTEGER, COL2 CHAR(2) ); SHOW TABLE TAB1; CREATE SET TABLE FINANCIAL.TAB1,NO FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL ( COL1 INTEGER, COL2 CHAR(2) CHARACTER SET LATIN NOT CASESPECIFIC) PRIMARY INDEX ( COL1 ); /* Disconnect and connect again in ANSI mode*/ Database Financial; CREATE TABLE FINANCIAL.TAB2 ( COL1 INTEGER, COL2 CHAR(2) ); SHOW TABLE TAB2; CREATE MULTISET TABLE TAB2,NO FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL ( COL1 INTEGER, COL2 CHAR(2) CHARACTER SET LATIN CASESPECIFIC) PRIMARY INDEX ( COL1 ); 23 The SHOW VIEW Command CREATE VIEW dept (dept_num,dept_name,budget,manager) AS SELECT department_number,department_name,budget_amount,manager_employee_numberr FROM CUSTOMER_SERVICE.department; 24 The SHOW MACRO Command CREATE MACRO get_depts AS (SELECT department_number,department_name,budget_amount,manager_employee_number FROM department;); To get Some Macros from DBC---- select B.DatabaseName, A.TVMNAME from DBC.TVM A, dbc.dbase B where A.tablekind = 'M' and A.DatabaseId = B.DatabaseID E.g: show macro DBC.ResOneNode; 25 Teradata Administrator 26 Teradata Administrator Open Teradata Administrator. This tool is used to perform database administration tasks on the associated Teradata 27 Teradata Administrator View Objects Its like a TOAD tool for Oracle. It lists all the Objects in a selected Database/User. The list view can be changed using Database Menu Option as below 28 Different actions can be performed on a selected Object. Explore options on a Table - Row Count, Browse, Space etc. Teradata Administrator Explore Objects 29 Teradata Administrator - Functions Teradata Administrator provides an easy-to-use Windows-based graphical interface to the Teradata RDBMS Data Dictionary. You may use Teradata Administrator to perform the following functions: Create, Modify and Drop Users or Databases Create Tables (using ANSI or Teradata syntax) Grant or Revoke access/system rights Copy Table, View or Macro definitions to another database, or to another system Drop or Rename Tables, Views or Macros Move space from one database to another Run an SQL query 30 Exercise Exercise Teradata SQL Assistant Exercise Teradata Administrator 31 Q/A Thank You