Tables and Volatile Tables

Size: px
Start display at page:

Download "Tables and Volatile Tables"

Transcription

1 Derived Tables and Volatile Tables After completing this module, you will be able to: Use permanent tables for ad-hoc queries. Use both forms of Derived table syntax. Recognize variations for each form of derived table. Create volatile tables for session use. Distinguish between various ad-hoc strategies. Identify volatile table limitations. Distinguish between the two ON COMMIT options. Use volatile tables within views and macros. Teradata Corporation Copyright All Rights Reserved.

2 Permanent Tables for Ad Hoc Queries Reasons for interim use of permanent tables? To allow SQL to perform operations that: May not be possible from a normalized table May require multiple SQL statements For denormalizations such as: Summary tables Repeating groups For intermediate results which will be needed: Frequently, or On an on-going basis CREATE TABLE Daily_Net_Trans (Account_Number INTEGER,Total_Trans_Amount DECIMAL(14,2)) UNIQUE PRIMARY INDEX (Account_Number); INSERT INTO Daily_Net_Trans SELECT Account_Number, SUM(Trans_Amount) FROM Trans GROUP BY Account_Number; SELECT * FROM Daily_Net_Trans WHERE Account_Number IN ( , , );

3 Pros and Cons for Ad Hoc Perm Tables Pros about this strategy. Simpler SQL Doesn t have to continually reproduce aggregate results. PI choice of table may facilitate subsequent SQL. Open for use by multiple sessions if needed. Space survives a restart. Subsequent updates, inserts, and deletes can be performed on the rows of the table. Cons about this strategy. Separate steps to create and populate table. Requires extra perm space for temp table. Table may need to be dropped when no longer needed. If not, then extra maintenance may be required. Data Dictionary access is necessary for creating and dropping

4 Temporary Table Choices Views (Taught in Introduction to SQL and known to students of this course) Local to a query Uses Spool Derived Tables (Taught in Introduction To SQL and known to students of this course) Local to the query Incorporated into SQL query syntax Discarded when query finishes No Data Dictionary involvement Volatile Tables (This course) Local to a session Uses CREATE VOLATILE TABLE syntax Discarded automatically at session end No Data Dictionary involvement Global Temporary Tables (This course) Local to a session Uses CREATE GLOBAL TEMPORARY TABLE syntax Materialized instance of table discarded at session end Creates and keeps table definition in Data Dictionary This Module

5 Derived Tables Derived tables: are ANSI standard. are database created tables that are used for a single query only. are discarded by the database when they are no longer required. are materialized into spool. are referenced and treated as a real table. must be defined by the author of the query, and require - a table name columns and their names a SELECT that is used to populate the table More common form: SELECT Last_Name, Salary_Amount, AvgSal FROM Employee e, (SELECT AVG(Salary_Amount) FROM Employee) AS AvgT (AvgSal) WHERE e.salary_amount > AvgT.AvgSal; Query to populate AvgT Table Name AvgT Column Name(s) AvgSal

6 Another Derived Table Syntax Form More common usage? SELECT Last_Name, Salary_Amount, AvgSal FROM Employee e, (SELECT AVG(Salary_Amount) FROM Employee) AS AvgT (AvgSal) WHERE e.salary_amount > AvgT.AvgSal; Query to populate AvgT Table Name AvgT Column Name(s) AvgSal Column Name(s) AvgSal Table Name AvgT Query to populate AvgT The SELECT (projection) appears after the derived table definition. WITH Form WITH AvgT (AvgSal) AS (SELECT AVG(Salary_Amount) FROM Employee) SELECT Last_Name, Salary_Amount, AvgSal FROM AvgT t, Employee e WHERE e.salary_amount > t.avgsal;

7 Derived Tables and Joins SELECT e.department_number, e.last_name, e.salary_amount, t.avgsal FROM Employee e JOIN (SELECT Department_Number AS Dept#, AVG(Salary_Amount) AS AvgSal FROM Employee GROUP BY 1) AS t ON e.department_number = t.dept# WHERE e.salary_amount > t.avgsal ORDER BY 1; WITH t (dept#, AvgSal) AS (SELECT Department_Number, AVG(Salary_Amount) FROM Employee GROUP BY 1) SELECT e.department_number, e.last_name, e.salary_amount, t.avgsal FROM Employee e JOIN t ON e.department_number = t.dept# WHERE e.salary_amount > t.avgsal ORDER BY 1; department_number last_name salary_amount AvgSal Morrissey Kubic Daly Brown Villegas Charles Wilson Ratzlaff Runyon

8 CREATE TABLE AS and Derived Tables CREATE MULTISET TABLE dlm.mindeptsal AS ( WITH Temp (Dept#, AvgSal) AS (SELECT Department_Number, AVG(Salary_Amount) FROM Employee GROUP BY 1) SELECT d1.department_name AS DeptName, e1.last_name AS LastName, e1.salary_amount AS Salary, temp.avgsal AS DeptAvg FROM Employee AS e1, Department AS d1, Temp WHERE e1.department_number = d1.department_number AND AND e1.department_number = Temp.Dept# Temp.AvgSal IN (SELECT MIN(AvgSal) FROM Temp) ) WITH DATA PRIMARY INDEX (LastName); Create a permanent table having the last name, department name, salary and average department salary for each employee in the department with the smallest average salary. Note the data type DeptName LastName Salary DeptAvg research and development Stein E 004 research and development Kanieski E 004 research and development Kubic? E 004

9 Volatile Table Syntax CREATE VOLATILE TABLE vt_deptsal (deptno SMALLINT,avgsal DEC(9,2),maxsal DEC(9,2),minsal DEC(9,2),sumsal DEC(9,2),empcnt SMALLINT); SHOW TABLE vt_deptsal Volatile tables are not defined in ANSI LOG indicates that a transaction journal is maintained. This is the default. CREATE SET VOLATILE TABLE DLM.vt_deptsal, FALLBACK, CHECKSUM = DEFAULT, LOG ( deptno SMALLINT, avgsal DECIMAL(9,2), maxsal DECIMAL(9,2), minsal DECIMAL(9,2), sumsal DECIMAL(9,2), empcnt SMALLINT) PRIMARY INDEX ( deptno ) ON COMMIT DELETE ROWS; NO LOG allows for better performance. ON COMMIT DELETE ROWS indicates to delete all table rows after a commit (end transaction). This is the default. ON COMMIT PRESERVE ROWS indicates to keep table rows at TXN end.

10 Pros and Cons of Volatile Tables Pros about this construct. Simpler SQL Doesn t have to continually reproduce aggregate results. PI choice of table may facilitate subsequent SQL. Local (private) to a session (i.e. can not be viewed from other sessions). Subsequent updates, inserts, and deletes can be performed on the rows of the table. Table is automatically dropped at session end or manually by user. No dictionary access required. Cons about this construct. Separate steps to create and populate table. Requires extra spool space for temp table. No secondary indexes allowed. Statistics can not be collected. Holds on to spool longer.

11 Volatile Table Restrictions Up to 1000 volatile tables are allowed for a single session. At the time you create a volatile table, the name must be unique among all global and permanent object names in the database that has the name of the login user. CREATE VOLATILE TABLE username.table1 CREATE VOLATILE TABLE table1 CREATE VOLATILE TABLE databasename.table1 Username must be that of logon. Default must be that of logon. Can not use spool of another database or user. Each session can use the same VT name (local to session). VT name cannot duplicate existing object name for this user Perm or Temp table names View names Macro names Trigger names, etc. FALLBACK: Electable but not often useful for VTs. VTs don t survive a system reset. Options not permitted: Permanent Journaling Referential Integrity CHECK constraints Column compression Column default values Column titles Named indexes

12 HELP and SHOW (Volatile) TABLE CREATE VOLATILE TABLE vt_deptsal1 ( deptno SMALLINT, avgsal DECIMAL(9,2), maxsal DECIMAL(9,2), minsal DECIMAL(9,2), sumsal DECIMAL(9,2), empcnt SMALLINT ); SHOW TABLE vt_deptsal1; HELP VOLATILE TABLE; Table Name Table Id vt_deptsal1 30C0BC vt_deptsal2 30C0BD HELP DATABASE command does not show VT s. Create the volatile table. CREATE SET VOLATILE TABLE DLM.vt_deptsal1, FALLBACK, CHECKSUM = DEFAULT, LOG ( deptno SMALLINT, avgsal DECIMAL(9,2), maxsal DECIMAL(9,2), minsal DECIMAL(9,2), sumsal DECIMAL(9,2), empcnt SMALLINT) PRIMARY INDEX ( deptno ) ON COMMIT DELETE ROWS; DROP TABLE vt_deptsal1

13 ON COMMIT DELETE ROWS (Implicit Transactions) Create a volatile table. CREATE VOLATILE TABLE vt_deptsal (deptno SMALLINT,avgsal DEC(9,2),maxsal DEC(9,2),minsal DEC(9,2),sumsal DEC(9,2),empcnt SMALLINT); Populate the volatile table with computed aggregates. INSERT INTO vt_deptsal SELECT dept,avg(sal),max(sal),min(sal), SUM(sal), COUNT(emp) FROM emp GROUP BY 1; SELECT * FROM vt_deptsal ORDER BY 3; *** Query completed. No rows found. Remember: The default is ON COMMIT DELETE ROWS Rows are deleted immediately after the insert for implicit transactions!

14 ON COMMIT DELETE ROWS (Explicit Transactions) Create a volatile table. CREATE VOLATILE TABLE vt_deptsal (deptno SMALLINT,avgsal DEC(9,2),maxsal DEC(9,2),minsal DEC(9,2),sumsal DEC(9,2),empcnt SMALLINT); BT; INSERT INTO vt_deptsal (1, 2, 3, 4, 5, 6); SELECT * FROM vt_deptsal; deptno avgsal maxsal minsal sumsal empcnt ET; SELECT * FROM vt_deptsal; *** Query completed. No rows found. The default of ON COMMIT DELETE ROWS deleted the rows immediately after the ET; This would work the same for ANSI mode explicit transactions.

15 ON COMMIT PRESERVE ROWS Create a volatile table. CREATE VOLATILE TABLE vt_deptsal (deptno SMALLINT,avgsal DEC(9,2),maxsal DEC(9,2),minsal DEC(9,2),sumsal DEC(9,2),empcnt SMALLINT) ON COMMIT PRESERVE ROWS; BT; INSERT INTO vt_deptsal (1, 2, 3, 4, 5, 6); SELECT * FROM vt_deptsal; deptno avgsal maxsal minsal sumsal empcnt ET; SELECT * FROM vt_deptsal; deptno avgsal maxsal minsal sumsal empcnt

16 Limitations The following commands are not applicable to VT s: COLLECT/DROP/HELP STATISTICS CREATE/DROP INDEX ALTER TABLE GRANT/REVOKE privileges DELETE DATABASE/USER (does not drop VT s) VT s may not: Use ACCESS LOGGING. Be RENAMEd. Be loaded with MultiLoad or FastLoad utilities.

17 Volatile Tables from Derived Tables CREATE MULTISET VOLATILE TABLE VT_MinDeptSal AS ( WITH Temp (Dept#, AvgSal) AS (SELECT Department_Number, AVG(Salary_Amount) FROM Employee GROUP BY 1) SELECT d1.department_name AS DeptName, e1.last_name AS LastName, e1.salary_amount AS Salary, temp.avgsal AS DeptAvg FROM Employee AS e1, Department AS d1, Temp WHERE e1.department_number = d1.department_number AND AND e1.department_number = Temp.Dept# Temp.AvgSal IN (SELECT MIN(AvgSal) FROM Temp) ) WITH DATA PRIMARY INDEX (LastName) ON COMMIT PRESERVE ROWS; SELECT * FROM VT_MinDeptSal; Create a Volatile table having the employee name, department name and salary for each employee in the department with the smallest average salary. HELP VOLATILE TABLE; Table Name Table Id VT_MinDeptSal 10C0B DeptName LastName Salary DeptAvg customer support Rogers E 004 customer support Johnson E 004 customer support Trader E 004 customer support Phillips E 004 customer support Machado E 004 customer support Brown E 004 customer support Hoover E 004

18 Use with Views and Macros REPLACE MACRO vt1 AS (CREATE VOLATILE TABLE vt_deptsal3 (deptno SMALLINT,avgsal DEC(9,2),empcnt SMALLINT) 1 ON COMMIT PRESERVE ROWS; ); Since spool does not survive a restart, Volatile tables are more likely to be used in an ad hoc environment. This usage is more reflective of batch processing. EXEC vt1; 2 Table must be created before doing the following REPLACE MACRO vt2 3 AS (INSERT vt_deptsal3 SELECT Department_Number, AVG(Salary_Amount), COUNT(Salary_Amount) FROM EMPLOYEE GROUP BY 1;); REPLACE VIEW vt3 AS SELECT e.last_name, 4 v.deptno, e.salary_amount, v.avgsal FROM Employee e, vt_deptsal3 v WHERE e.department_number = v.deptno AND e.salary_amount > v.avgsal; Example of usage. EXEC vt1; *** Table has been created. EXEC vt2; *** Insert completed. 8 rows added. SELECT * FROM vt3 WHERE deptno = 401; last_name deptno salary_amount avgsal Brown Trader Rogers Johnson

19 Another View and Macro Strategy REPLACE MACRO vt1 1 AS (CREATE VOLATILE TABLE vt_deptsal3 AS (SELECT Department_Number AS deptno, AVG(Salary_Amount) AS avgsal, COUNT(Salary_Amount) AS salcnt FROM Employee GROUP BY 1) WITH DATA UNIQUE PRIMARY INDEX (deptno) ON COMMIT PRESERVE ROWS; ); Compare this sequence to the one on the previous page. EXEC vt1; 2 Table must be created before doing the following. REPLACE VIEW vt2 AS SELECT e.last_name, v.deptno, e.salary_amount (DEC(10,2)), v.avgsal (DEC(10,2)) FROM Employee e, vt_deptsal3 v WHERE e.department_number = v.deptno AND e.salary_amount > v.avgsal; 3 Example of usage. EXEC vt1; SELECT * FROM vt2 WHERE deptno = 401; last_name deptno salary_amount avgsal Brown Trader Johnson Rogers

20 Volatile Table Quiz In the following exercise, User A has two parallel sessions. Assuming the given sequence of events, which will succeed, which will fail, and why? User A CVT = Create Volatile Table CPT = Create Permanent Table Session 1 Session 2 Success/Failure/Reason CVT T1 CVT T1 SUCCESS SUCCESS CPT T2 SUCCESS CVT T2 FAILURE CVT T3 SUCCESS CPT T3 SUCCESS INSERT T3 SUCCESS (VT3) CVT T3 FAILURE INSERT T3 SUCCESS (PT3) DROP T3 SELECT * FROM T3 SUCCESS (VT3) SUCCESS (PT3)

21 Module 2: Summary There are two forms for writing derived tables: WITH and FROM. Views, Derived, Global and Volatile tables are all examples of temporary instance objects. Views, Derived tables and Volatile tables all use spool. ON COMMIT DELETE ROWS is the default for volatile tables. Volatile tables last until the end of the user s session logoff, when the database drops them automatically. Volatile tables are best suited for ad-hoc usage.

22 Module 2: Review Questions True or False: 1. You can define a volatile table with a unique primary index. True 2. The option ON COMMIT DELETE ROWS will result in the inserted rows being immediately deleted after the insert. False this is true only for implicit transactions. 3. You can not perform a SHOW TABLE on a derived table. True 4. You cannot qualify a volatile table create with a database name other than your user name. True 5. Volatile tables and derived tables use the same kind of space. True 6. You can create hundreds of derived tables for a single query. False True in TD13 7. You can drop a volatile table at anytime during your session. True

23 Module 2: Lab Exercise 1) Use the most compact method you can to create a volatile table based on the definition of the Department table and then populate it with data from the department table. Use the preserve option. Select all rows from the table you created. 2) Create another volatile table that averages the salary amounts for each department. Now issue a HELP command to verify the existence of the two volatile tables that you created. Do SHOW TABLE on one of them and then drop the first one and repeat the earlier HELP command. 3) Write a query using a derived table that lists employees that have salaries greater than average for their department. Contrast this with a query that does this referencing the table created in #2.

Tables From Existing Tables

Tables From Existing Tables Creating Tables From Existing Tables After completing this module, you will be able to: Create a clone of an existing table. Create a new table from many tables using a SQL SELECT. Define your own table

More information

Teradata. This was compiled in order to describe Teradata and provide a brief overview of common capabilities and queries.

Teradata. This was compiled in order to describe Teradata and provide a brief overview of common capabilities and queries. Teradata This was compiled in order to describe Teradata and provide a brief overview of common capabilities and queries. What is it? Teradata is a powerful Big Data tool that can be used in order to quickly

More information

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO INSERT INTO DEPT VALUES(4, 'Prog','MO'); The result

More information

Objectives. After completing this lesson, you should be able to do the following:

Objectives. After completing this lesson, you should be able to do the following: Objectives After completing this lesson, you should be able to do the following: Describe the types of problems that subqueries can solve Define subqueries List the types of subqueries Write single-row

More information

Teradata Database SQL Fundamentals

Teradata Database SQL Fundamentals Teradata Database SQL Fundamentals Release 16.20 April 2018 B035-1141-162K Copyright and Trademarks Copyright 2000-2018 by Teradata. All Rights Reserved. All copyrights and trademarks used in Teradata

More information

Overview. Data Integrity. Three basic types of data integrity. Integrity implementation and enforcement. Database constraints Transaction Trigger

Overview. Data Integrity. Three basic types of data integrity. Integrity implementation and enforcement. Database constraints Transaction Trigger Data Integrity IT 4153 Advanced Database J.G. Zheng Spring 2012 Overview Three basic types of data integrity Integrity implementation and enforcement Database constraints Transaction Trigger 2 1 Data Integrity

More information

GIFT Department of Computing Science. CS-217: Database Systems. Lab-4 Manual. Reporting Aggregated Data using Group Functions

GIFT Department of Computing Science. CS-217: Database Systems. Lab-4 Manual. Reporting Aggregated Data using Group Functions GIFT Department of Computing Science CS-217: Database Systems Lab-4 Manual Reporting Aggregated Data using Group Functions V3.0 4/28/2016 Introduction to Lab-4 This lab further addresses functions. It

More information

Teradata SQL Features Overview Version

Teradata SQL Features Overview Version Table of Contents Teradata SQL Features Overview Version 14.10.0 Module 0 - Introduction Course Objectives... 0-4 Course Description... 0-6 Course Content... 0-8 Module 1 - Teradata Studio Features Optimize

More information

Sample Question Paper

Sample Question Paper Sample Question Paper Marks : 70 Time:3 Hour Q.1) Attempt any FIVE of the following. a) List any four applications of DBMS. b) State the four database users. c) Define normalization. Enlist its type. d)

More information

INSTRUCTOR-LED TRAINING COURSE

INSTRUCTOR-LED TRAINING COURSE INSTRUCTOR-LED TRAINING COURSE TERADATA TERADATA Lecture/Lab ILT 25968 4 Days COURSE DESCRIPTION This course defines the processes and procedures to follow when designing and implementing a Teradata system.

More information

Visit for more.

Visit  for more. Chapter 9: More On Database & SQL Advanced Concepts Informatics Practices Class XII (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra,

More information

5 Integrity Constraints and Triggers

5 Integrity Constraints and Triggers 5 Integrity Constraints and Triggers 5.1 Integrity Constraints In Section 1 we have discussed three types of integrity constraints: not null constraints, primary keys, and unique constraints. In this section

More information

SQL. Char (30) can store ram, ramji007 or 80- b

SQL. Char (30) can store ram, ramji007 or 80- b SQL In Relational database Model all the information is stored on Tables, these tables are divided into rows and columns. A collection on related tables are called DATABASE. A named table in a database

More information

Teradata Certified Professional Program Teradata V2R5 Certification Guide

Teradata Certified Professional Program Teradata V2R5 Certification Guide Professional Program Teradata Certification Guide The Professional Program team welcomes you to the Teradata Certification Guide. The guide provides comprehensive information about Teradata certification

More information

Creating and Managing Tables Schedule: Timing Topic

Creating and Managing Tables Schedule: Timing Topic 9 Creating and Managing Tables Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the

More information

Teradata Basics Class Outline

Teradata Basics Class Outline Teradata Basics Class Outline CoffingDW education has been customized for every customer for the past 20 years. Our classes can be taught either on site or remotely via the internet. Education Contact:

More information

PASSTCERT QUESTION & ANSWER

PASSTCERT QUESTION & ANSWER PASSTCERT QUESTION & ANSWER Higher Quality Better Service! Weofferfreeupdateserviceforoneyear HTTP://WWW.PASSTCERT.COM Exam : NR0-013 Title : Teradata Sql v2r5 Exam Version : DEMO 1 / 5 1.Which three statements

More information

AURA ACADEMY Training With Expertised Faculty Call Us On For Free Demo

AURA ACADEMY Training With Expertised Faculty Call Us On For Free Demo AURA ACADEMY Course Content: TERADATA Database 14 1. TERADATA Warehouse and Competitiveness Opportunities of TERADATA in the enterprise. What is TERADATA-RDBMS/DWH? TERADATA 14 & Other versions( 13.10,13,12,v2r7/r6/r5)

More information

Database implementation Further SQL

Database implementation Further SQL IRU SEMESTER 2 January 2010 Semester 1 Session 2 Database implementation Further SQL Objectives To be able to use more advanced SQL statements, including Renaming columns Order by clause Aggregate functions

More information

Database Systems Laboratory 5 Grouping, DCL & TCL

Database Systems Laboratory 5 Grouping, DCL & TCL Database Systems Laboratory 5 School of Computer Engineering, KIIT University 5.1 1 2 3 4 5.2 GROUP BY clause GROUP BY clause is used for grouping data. The column appearing in SELECT statement must also

More information

Chapter 16: Advanced MySQL- Grouping Records and Joining Tables. Informatics Practices Class XII. By- Rajesh Kumar Mishra

Chapter 16: Advanced MySQL- Grouping Records and Joining Tables. Informatics Practices Class XII. By- Rajesh Kumar Mishra Chapter 16: Advanced MySQL- Grouping Records and Joining Tables Informatics Practices Class XII By- Rajesh Kumar Mishra PGT (Comp.Sc.) KV No.1, AFS, Suratgarh (Raj.) e-mail : rkmalld@gmail.com Grouping

More information

IBM A Assessment: DB2 9 Fundamentals-Assessment. Download Full Version :

IBM A Assessment: DB2 9 Fundamentals-Assessment. Download Full Version : IBM A2090-730 Assessment: DB2 9 Fundamentals-Assessment Download Full Version : http://killexams.com/pass4sure/exam-detail/a2090-730 C. 2 D. 3 Answer: C QUESTION: 294 In which of the following situations

More information

You should have a basic understanding of Relational concepts and basic SQL. It will be good if you have worked with any other RDBMS product.

You should have a basic understanding of Relational concepts and basic SQL. It will be good if you have worked with any other RDBMS product. About the Tutorial is a popular Relational Database Management System (RDBMS) suitable for large data warehousing applications. It is capable of handling large volumes of data and is highly scalable. This

More information

RDBMS Using Oracle. Use of IN OUT

RDBMS Using Oracle. Use of IN OUT RDBMS Using Oracle PL/SQL Procedural Language/Structural Query Language PL/SQL Procedures Kamran.Munir@niit.edu.pk Use of IN OUT Example: Format phone Procedure 1 Example: Format phone Procedure Input

More information

Creating Other Schema Objects

Creating Other Schema Objects Creating Other Schema Objects Objectives After completing this lesson, you should be able to do the following: Create simple and complex views Retrieve data from views Database Objects Object Table View

More information

Creating Other Schema Objects. Copyright 2004, Oracle. All rights reserved.

Creating Other Schema Objects. Copyright 2004, Oracle. All rights reserved. Creating Other Schema Objects Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Create simple and complex views Retrieve data

More information

Slicing and Dicing Data in CF and SQL: Part 1

Slicing and Dicing Data in CF and SQL: Part 1 Slicing and Dicing Data in CF and SQL: Part 1 Charlie Arehart Founder/CTO Systemanage carehart@systemanage.com SysteManage: Agenda Slicing and Dicing Data in Many Ways Handling Distinct Column Values Manipulating

More information

Exam code: Exam name: Database Fundamentals. Version 16.0

Exam code: Exam name: Database Fundamentals. Version 16.0 98-364 Number: 98-364 Passing Score: 800 Time Limit: 120 min File Version: 16.0 Exam code: 98-364 Exam name: Database Fundamentals Version 16.0 98-364 QUESTION 1 You have a table that contains the following

More information

More SQL: Complex Queries, Triggers, Views, and Schema Modification

More SQL: Complex Queries, Triggers, Views, and Schema Modification Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Outline More Complex SQL Retrieval Queries

More information

More SQL: Complex Queries, Triggers, Views, and Schema Modification

More SQL: Complex Queries, Triggers, Views, and Schema Modification Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Outline More Complex SQL Retrieval Queries

More information

Database Programming with SQL

Database Programming with SQL Database Programming with SQL 7-2 Objectives In this lesson, you will learn to: Construct and execute a SELECT statement to access data from more than one table using a nonequijoin Create and execute a

More information

Oracle MOOC: SQL Fundamentals

Oracle MOOC: SQL Fundamentals Week 4 Homework for Lesson 4 Homework is your chance to put what you've learned in this lesson into practice. This homework is not "graded" and you are encouraged to write additional code beyond what is

More information

Retrieving Data from Multiple Tables

Retrieving Data from Multiple Tables Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Database Lab (ECOM 4113) Lab 5 Retrieving Data from Multiple Tables Eng. Mohammed Alokshiya November 2, 2014 An JOIN clause

More information

Chapter 4: Intermediate SQL

Chapter 4: Intermediate SQL Chapter 4: Intermediate SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use 4.1 Join Expressions Let s first review the joins from ch.3 4.2 1 SELECT * FROM student, takes

More information

Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query

More information

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of The SQL Query Language Data Definition Basic Query

More information

Creating SQL Tables and using Data Types

Creating SQL Tables and using Data Types Creating SQL Tables and using Data Types Aims: To learn how to create tables in Oracle SQL, and how to use Oracle SQL data types in the creation of these tables. Outline of Session: Given a simple database

More information

The SQL data-definition language (DDL) allows defining :

The SQL data-definition language (DDL) allows defining : Introduction to SQL Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query Structure Additional Basic Operations Set Operations Null Values Aggregate Functions Nested Subqueries

More information

Relational Algebra. Procedural language Six basic operators

Relational Algebra. Procedural language Six basic operators Relational algebra Relational Algebra Procedural language Six basic operators select: σ project: union: set difference: Cartesian product: x rename: ρ The operators take one or two relations as inputs

More information

Lessons with Tera-Tom Teradata Architecture Video Series

Lessons with Tera-Tom Teradata Architecture Video Series Lessons with Tera-Tom Teradata Architecture Video Series For More Information Contact: Thomas Coffing Chief Executive Officer Coffing Data Warehousing Cell: 513-300-0341 Email: Tom.Coffing@coffingdw.com

More information

Slides by: Ms. Shree Jaswal

Slides by: Ms. Shree Jaswal Slides by: Ms. Shree Jaswal Overview of SQL, Data Definition Commands, Set operations, aggregate function, null values, Data Manipulation commands, Data Control commands, Views in SQL, Complex Retrieval

More information

20 Essential Oracle SQL and PL/SQL Tuning Tips. John Mullins

20 Essential Oracle SQL and PL/SQL Tuning Tips. John Mullins 20 Essential Oracle SQL and PL/SQL Tuning Tips John Mullins jmullins@themisinc.com www.themisinc.com www.themisinc.com/webinars Presenter John Mullins Themis Inc. (jmullins@themisinc.com) 30+ years of

More information

Data Modelling and Databases. Exercise Session 7: Integrity Constraints

Data Modelling and Databases. Exercise Session 7: Integrity Constraints Data Modelling and Databases Exercise Session 7: Integrity Constraints 1 Database Design Textual Description Complete Design ER Diagram Relational Schema Conceptual Modeling Logical Modeling Physical Modeling

More information

To understand the concept of candidate and primary keys and their application in table creation.

To understand the concept of candidate and primary keys and their application in table creation. CM0719: Database Modelling Seminar 5 (b): Candidate and Primary Keys Exercise Aims: To understand the concept of candidate and primary keys and their application in table creation. Outline of Activity:

More information

SQL Retrieving Data from Multiple Tables

SQL Retrieving Data from Multiple Tables The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Database Lab (ECOM 4113) Lab 5 SQL Retrieving Data from Multiple Tables Eng. Ibraheem Lubbad An SQL JOIN clause is used

More information

Databases - 5. Problems with the relational model Functions and sub-queries

Databases - 5. Problems with the relational model Functions and sub-queries Databases - 5 Problems with the relational model Functions and sub-queries Problems (1) To store information about real life entities, we often have to cut them up into separate tables Problems (1) To

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2017 CS 348 (Intro to DB Mgmt) SQL

More information

1 SQL Structured Query Language

1 SQL Structured Query Language 1 SQL Structured Query Language 1.1 Tables In relational database systems (DBS) data are represented using tables (relations). A query issued against the DBS also results in a table. A table has the following

More information

Principles of Data Management

Principles of Data Management Principles of Data Management Alvin Lin August 2018 - December 2018 Structured Query Language Structured Query Language (SQL) was created at IBM in the 80s: SQL-86 (first standard) SQL-89 SQL-92 (what

More information

Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601

Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601 Techno India Batanagar Computer Science and Engineering Model Questions Subject Name: Database Management System Subject Code: CS 601 Multiple Choice Type Questions 1. Data structure or the data stored

More information

SQL DDL II. CS121: Relational Databases Fall 2017 Lecture 8

SQL DDL II. CS121: Relational Databases Fall 2017 Lecture 8 SQL DDL II CS121: Relational Databases Fall 2017 Lecture 8 Last Lecture 2 Covered SQL constraints NOT NULL constraints CHECK constraints PRIMARY KEY constraints FOREIGN KEY constraints UNIQUE constraints

More information

Subquery: There are basically three types of subqueries are:

Subquery: There are basically three types of subqueries are: Subquery: It is also known as Nested query. Sub queries are queries nested inside other queries, marked off with parentheses, and sometimes referred to as "inner" queries within "outer" queries. Subquery

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2016 CS 348 (Intro to DB Mgmt) SQL

More information

What would you do if you knew?

What would you do if you knew? What would you do if you knew? Teradata Database SQL Fundamentals Release 16.00 B035-1141-160K December 2016 The product or products described in this book are licensed products of Teradata Corporation

More information

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan COSC 304 Introduction to Database Systems SQL DDL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca SQL Overview Structured Query Language or SQL is the standard query language

More information

3. Getting data out: database queries. Querying

3. Getting data out: database queries. Querying 3. Getting data out: database queries Querying... 1 Queries and use cases... 2 The GCUTours database tables... 3 Project operations... 6 Select operations... 8 Date formats in queries... 11 Aggregates...

More information

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement Chapter 4 Basic SQL Basic SQL SQL language Considered one of the major reasons for the commercial success of relational databases SQL Structured Query Language Statements for data definitions, queries,

More information

DATABASE DEVELOPMENT (H4)

DATABASE DEVELOPMENT (H4) IMIS HIGHER DIPLOMA QUALIFICATIONS DATABASE DEVELOPMENT (H4) Friday 3 rd June 2016 10:00hrs 13:00hrs DURATION: 3 HOURS Candidates should answer ALL the questions in Part A and THREE of the five questions

More information

1 SQL Structured Query Language

1 SQL Structured Query Language 1 SQL Structured Query Language 1.1 Tables In relational database systems (DBS) data are represented using tables (relations). A query issued against the DBS also results in a table. A table has the following

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 7 More SQL: Complex Queries, Triggers, Views, and Schema Modification Slide 7-2 Chapter 7 Outline More Complex SQL Retrieval Queries Specifying Semantic Constraints as Assertions and Actions as

More information

Outer Join, More on SQL Constraints

Outer Join, More on SQL Constraints Outer Join, More on SQL Constraints CS430/630 Lecture 10 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Outer Joins Include in join result non-matching tuples Result tuple

More information

ASSIGNMENT NO Computer System with Open Source Operating System. 2. Mysql

ASSIGNMENT NO Computer System with Open Source Operating System. 2. Mysql ASSIGNMENT NO. 3 Title: Design at least 10 SQL queries for suitable database application using SQL DML statements: Insert, Select, Update, Delete with operators, functions, and set operator. Requirements:

More information

SYSTEM CODE COURSE NAME DESCRIPTION SEM

SYSTEM CODE COURSE NAME DESCRIPTION SEM Course: CS691- Database Management System Lab PROGRAMME: COMPUTER SCIENCE & ENGINEERING DEGREE:B. TECH COURSE: Database Management System Lab SEMESTER: VI CREDITS: 2 COURSECODE: CS691 COURSE TYPE: Practical

More information

Join, Sub queries and set operators

Join, Sub queries and set operators Join, Sub queries and set operators Obtaining Data from Multiple Tables EMPLOYEES DEPARTMENTS Cartesian Products A Cartesian product is formed when: A join condition is omitted A join condition is invalid

More information

GIFT Department of Computing Science. CS-217/224: Database Systems. Lab-5 Manual. Displaying Data from Multiple Tables - SQL Joins

GIFT Department of Computing Science. CS-217/224: Database Systems. Lab-5 Manual. Displaying Data from Multiple Tables - SQL Joins GIFT Department of Computing Science CS-217/224: Database Systems Lab-5 Manual Displaying Data from Multiple Tables - SQL Joins V3.0 5/5/2016 Introduction to Lab-5 This lab introduces students to selecting

More information

Chapter 6: Formal Relational Query Languages

Chapter 6: Formal Relational Query Languages Chapter 6: Formal Relational Query Languages Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 6: Formal Relational Query Languages Relational Algebra Tuple Relational

More information

Displaying Data from Multiple Tables. Copyright 2004, Oracle. All rights reserved.

Displaying Data from Multiple Tables. Copyright 2004, Oracle. All rights reserved. Displaying Data from Multiple Tables Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Write SELECT statements to access data

More information

QQ Group

QQ Group QQ Group: 617230453 1 Extended Relational-Algebra-Operations Generalized Projection Aggregate Functions Outer Join 2 Generalized Projection Extends the projection operation by allowing arithmetic functions

More information

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables INDEX Exercise No Title 1 Basic SQL Statements 2 Restricting and Sorting Data 3 Single Row Functions 4 Displaying data from multiple tables 5 Creating and Managing Tables 6 Including Constraints 7 Manipulating

More information

Database Management Systems Paper Solution

Database Management Systems Paper Solution Database Management Systems Paper Solution Following questions have been asked in GATE CS exam. 1. Given the relations employee (name, salary, deptno) and department (deptno, deptname, address) Which of

More information

EXISTS NOT EXISTS WITH

EXISTS NOT EXISTS WITH Subquery II. Objectives After completing this lesson, you should be able to do the following: Write a multiple-column subquery Use scalar subqueries in SQL Solve problems with correlated subqueries Update

More information

UNIT-IV (Relational Database Language, PL/SQL)

UNIT-IV (Relational Database Language, PL/SQL) UNIT-IV (Relational Database Language, PL/SQL) Section-A (2 Marks) Important questions 1. Define (i) Primary Key (ii) Foreign Key (iii) unique key. (i)primary key:a primary key can consist of one or more

More information

Database 2: Slicing and Dicing Data in CF and SQL

Database 2: Slicing and Dicing Data in CF and SQL Database 2: Slicing and Dicing Data in CF and SQL Charlie Arehart Founder/CTO Systemanage carehart@systemanage.com SysteManage: Agenda Slicing and Dicing Data in Many Ways Handling Distinct Column Values

More information

Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management

Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management 12 Advanced Topics Objectives Use indexes to improve database performance Examine the security features of a DBMS Discuss entity, referential, and legal-values integrity Make changes to the structure of

More information

Database Systems Relational Model. A.R. Hurson 323 CS Building

Database Systems Relational Model. A.R. Hurson 323 CS Building Relational Model A.R. Hurson 323 CS Building Relational data model Database is represented by a set of tables (relations), in which a row (tuple) represents an entity (object, record) and a column corresponds

More information

More SQL: Complex Queries, Triggers, Views, and Schema Modification

More SQL: Complex Queries, Triggers, Views, and Schema Modification Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Outline More Complex SQL Retrieval Queries

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Alexandra Roatiş David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2016 CS 348 SQL Winter

More information

The Relational Algebra

The Relational Algebra The Relational Algebra Relational Algebra Relational algebra is the basic set of operations for the relational model These operations enable a user to specify basic retrieval requests (or queries) 27-Jan-14

More information

Teradata 14 Certification Exams Objectives. TE0-143 Teradata 14 Physical Design and Implementation

Teradata 14 Certification Exams Objectives. TE0-143 Teradata 14 Physical Design and Implementation Teradata 14 Certification Exams Objectives The high level objectives represent the general content areas. The more detailed information below the objective indicates representative topic areas. All Teradata

More information

Chapter 4 How to retrieve data from two tables

Chapter 4 How to retrieve data from two tables Chapter 4 How to retrieve data from two tables PL/SQL, C4 2008, Mike Murach & Associates, Inc. Slide 1 Objectives Applied Use the explicit syntax to code an inner join that returns data from a single table

More information

CSEN 501 CSEN501 - Databases I

CSEN 501 CSEN501 - Databases I CSEN501 - Databases I Lecture 5: Structured Query Language (SQL) Prof. Dr. Slim slim.abdennadher@guc.edu.eg German University Cairo, Faculty of Media Engineering and Technology Structured Query Language:

More information

SQL STRUCTURED QUERY LANGUAGE

SQL STRUCTURED QUERY LANGUAGE STRUCTURED QUERY LANGUAGE SQL Structured Query Language 4.1 Introduction Originally, SQL was called SEQUEL (for Structured English QUery Language) and implemented at IBM Research as the interface for an

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2012 CS 348 (Intro to DB

More information

After completing this unit, you should be able to: Use inner joins to retrieve data from more than one table

After completing this unit, you should be able to: Use inner joins to retrieve data from more than one table JOIN Objectives After completing this unit, you should be able to: Use inner joins to retrieve data from more than one table Use outer joins complementing inner joins Sample Tables for Unit EMPLOYEE EMPNO

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2012 CS 348 (Intro to DB

More information

ITCertMaster. Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way!

ITCertMaster.  Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way! ITCertMaster Safe, simple and fast. 100% Pass guarantee! http://www.itcertmaster.com IT Certification Guaranteed, The Easy Way! Exam : 1Z0-870 Title : MySQL 5.0, 5.1 and 5.5 Certified Associate Exam Vendors

More information

Downloaded from

Downloaded from Lesson 16: Table and Integrity Constraints Integrity Constraints are the rules that a database must follow at all times. Various Integrity constraints are as follows:- 1. Not Null: It ensures that we cannot

More information

Basic SQL. Basic SQL. Basic SQL

Basic SQL. Basic SQL. Basic SQL Basic SQL Dr Fawaz Alarfaj Al Imam Mohammed Ibn Saud Islamic University ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation Basic SQL Structured

More information

Chapter. Relational Database Concepts COPYRIGHTED MATERIAL

Chapter. Relational Database Concepts COPYRIGHTED MATERIAL Chapter Relational Database Concepts 1 COPYRIGHTED MATERIAL Every organization has data that needs to be collected, managed, and analyzed. A relational database fulfills these needs. Along with the powerful

More information

Microsoft MOS- Using Microsoft Office Access Download Full Version :

Microsoft MOS- Using Microsoft Office Access Download Full Version : Microsoft 77-605 MOS- Using Microsoft Office Access 2007 Download Full Version : http://killexams.com/pass4sure/exam-detail/77-605 QUESTION: 120 Peter works as a Database Designer for AccessSoft Inc. The

More information

Testpassport.

Testpassport. Testpassport http://www.testpassport.cn Exam : C2090-614 Title : DB2 10.1 Advanced DBA for Linux UNIX and Windows Version : Demo 1 / 5 1.Which constraints are used to tell the DB2 Optimizer to consider

More information

Real-World Performance Training SQL Introduction

Real-World Performance Training SQL Introduction Real-World Performance Training SQL Introduction Real-World Performance Team Basics SQL Structured Query Language Declarative You express what you want to do, not how to do it Despite the name, provides

More information

SQL Server. Management Studio. Chapter 3. In This Chapter. Management Studio. c Introduction to SQL Server

SQL Server. Management Studio. Chapter 3. In This Chapter. Management Studio. c Introduction to SQL Server Chapter 3 SQL Server Management Studio In This Chapter c Introduction to SQL Server Management Studio c Using SQL Server Management Studio with the Database Engine c Authoring Activities Using SQL Server

More information

VU Mobile Powered by S NO Group All Rights Reserved S NO Group 2013

VU Mobile Powered by S NO Group All Rights Reserved S NO Group 2013 1 CS403 Final Term Solved MCQs & Papers Mega File (Latest All in One) Question # 1 of 10 ( Start time: 09:32:20 PM ) Total Marks: 1 Each table must have a key. primary (Correct) secondary logical foreign

More information

IBM DB2 9 Family Fundamentals. Download Full Version :

IBM DB2 9 Family Fundamentals. Download Full Version : IBM 000-730 DB2 9 Family Fundamentals Download Full Version : http://killexams.com/pass4sure/exam-detail/000-730 Answer: D QUESTION: 292 The EMPLOYEE table contains the following information: EMPNO NAME

More information

151 Mixed bag of HOTS questions from VB 15 A VB program accepts a number in a text box and rounds the number to 0 decimal places. Write the VB code under the button cmdround to achieve this feature. Do

More information

Sun Certified MySQL Associate

Sun Certified MySQL Associate 310-814 Sun Certified MySQL Associate Version 3.1 QUESTION NO: 1 Adam works as a Database Administrator for a company. He creates a table named Students. He wants to create a new table named Class with

More information

Inputs. Decisions. Leads to

Inputs. Decisions. Leads to Chapter 6: Physical Database Design and Performance Modern Database Management 9 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Heikki Topi 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Objectives

More information

ORACLE 12C NEW FEATURE. A Resource Guide NOV 1, 2016 TECHGOEASY.COM

ORACLE 12C NEW FEATURE. A Resource Guide NOV 1, 2016 TECHGOEASY.COM ORACLE 12C NEW FEATURE A Resource Guide NOV 1, 2016 TECHGOEASY.COM 1 Oracle 12c New Feature MULTITENANT ARCHITECTURE AND PLUGGABLE DATABASE Why Multitenant Architecture introduced with 12c? Many Oracle

More information

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C 0 0 3 2 LIST OF EXPERIMENTS: 1. Creation of a database and writing SQL queries to retrieve information from the database. 2. Performing Insertion,

More information