* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Designing 3NF for Ad Hoc Queries
Survey
Document related concepts
Relational algebra wikipedia , lookup
Serializability wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Microsoft Access wikipedia , lookup
Oracle Database wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Functional Database Model wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Concurrency control wikipedia , lookup
Ingres (database) wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Versant Object Database wikipedia , lookup
Relational model wikipedia , lookup
Clusterpoint wikipedia , lookup
Transcript
Introduction to Teradata Client Tools Introduction to Teradata SQL OBJECTIVES : Teradata Product Components. Accessing Teradata – Database / User Teradata SQL Assistant Teradata Administrator 2 Teradata Database 12.0 Product Components 3 Teradata User/Database Organization DBC Sys_Calendar Spool_Reserve SysAdmin SystemFE QCD CrashDumps To ensure space will always be available for spool ... 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%.) SYSDBA Users View, Macro, Temporary and Stored Table Procedure Databases Databases Database (1) Database (1) (2) 4 Users and Databases DBC SYSDBA Human_Resources Personnel PR01 PR02 Accounting Benefits PR03 BF01 BF02 BF03 You can grant CREATE DATABASE authority to any user. The user may then create other users and databases from: • The user’s own space, or • The space of another user or database (if authorized). 5 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 6 Teradata SQL Assistant 7 Teradata SQL Assistant • Open the Teradata SQL Assistant. • This is the interface to work with the Teradata SQL 8 Connect to Database 9 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. 10 SQL Assistant – Different Windows Explain each Window – Database Explorer Tree, Query Window, Answer Set Window, History Window 11 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; 12 SQL Assistant – Tools - Options 13 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. 14 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 HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP DATABASE databasename; USER username; TABLE tablename; VIEW viewname; MACRO macroname; COLUMN table or viewname.*; (all columns) COLUMN table or viewname.colname . . ., colname; INDEX tablename; STATISTICS tablename; CONSTRAINT constraintname; JOIN INDEX join_indexname; HELP TRIGGER triggername; 15 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=2000000 SPOOL=3000000 TEMPORARY = 1000000 DEFAULT DATABASE = TESTUSER ; GRANT SELECT ON DBC TO TESTUSER; Log off & log on using TESTUSER 16 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 17 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 18 The HELP DATABASE Command The HELP DATABASE command shows all objects in the database specified. HELP DATABASE FINANCIAL; Table/View/Macro name accts checking_acct checking_tran credit_acct credit_tran customer Kind T T T T T 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. 19 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; SHOW VIEW viewname; CREATE TABLE statement CREATE VIEW statement SHOW MACRO macroname; CREATE MACRO statement 20 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 ); 21 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 ); 22 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; 23 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; 24 Teradata Administrator 25 Teradata Administrator Open Teradata Administrator. This tool is used to perform database administration tasks on the associated Teradata 26 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 27 Teradata Administrator – Explore Objects Different actions can be performed on a selected Object. Explore options on a Table - Row Count, Browse, Space etc…. 28 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 29 Exercise •Exercise – Teradata SQL Assistant •Exercise – Teradata Administrator 30 Q/A Thank You 31