Tables From Existing Tables
|
|
- Jennifer Blake
- 5 years ago
- Views:
Transcription
1 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 attributes for the new table. Define your own column attributes for the new table. Use the WITH DATA option to populate the new table or leave it empty. Propagate statistics to your new table from the sources. Teradata Corporation Copyright All Rights Reserved.
2 SQL Assistant Cloned Table This Process may be followed with an insert to populate the target table. 3. Change database name and submit 1. Right-click and Show Definition 2. Copy and Paste into query window
3 Create Table AS This form of the syntax is used to create an exact copy of another table. CREATE TABLE SQL01.Employee AS Employee_Sales.Employee WITH [NO] DATA; SHOW TABLE SQL01.Employee; Any slight variation of this syntax may not create an exact copy. WITH DATA or WITH NO DATA is required to either include the rows from the source table, or leave the created table empty. CREATE SET TABLE SQL01.Employee,FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL, CHECKSUM = DEFAULT ( 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 FORMAT 'YYYY-MM-DD' NOT NULL, birthdate DATE FORMAT 'YYYY-MM-DD' NOT NULL, salary_amount DECIMAL(10,2) NOT NULL) UNIQUE PRIMARY INDEX ( employee_number );
4 Cloning Attributes CREATE TABLE SQL01.Employee AS Employee_Sales.Employee WITH DATA; CREATE TABLE SQL01.Employee AS Employee_Sales.Employee WITH NO DATA; Most standard column attributes are copied: Column names Data types Default values NOT NULL constraints CHECK constraints UNIQUE constraints PRIMARY KEY constraints Some attributes are not copied: These attributes involve parent-child relationships. REFERENCES (Foreign Key) constraints Triggers (which reference source table) The sourcing objects may be tables or views!
5 Changing Table Attributes Attributes may be overridden as part of a CREATE TABLE...AS statement CREATE MULTISET TABLE dept1, FALLBACK AS department WITH NO DATA This will keep the UPI and make the new table fallback and multiset. CREATE TABLE dept1 AS department WITH NO DATA UNIQUE INDEX (department_name); The inclusion of the secondary index causes the primary index to default to the first defined column as a NUPI and use the database default for fallback. CREATE TABLE dept1 AS department WITH NO DATA UNIQUE PRIMARY INDEX (Employee_Number) UNIQUE INDEX (department_name); This will keep the UPI and add the USI.
6 Using Subqueries to Customize Tables For subquery forms, all table defaults not overridden are chosen. In this example, the source table is NO FALLBACK. CREATE TABLE emp1 AS (SELECT employee_number,department_number,salary_amount FROM employee) WITH NO DATA; When creating tables using subqueries: CREATE SET TABLE emp1, FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL ( employee_number INTEGER, department_number INTEGER, salary_amount DECIMAL(10,2)) PRIMARY INDEX ( employee_number ); Subqueries can include: Table attributes (FALLBACK) are not copied from source table. Secondary indexes (if exist) are not copied from source table. First column listed becomes a NUPI unless otherwise specified. Join expressions Aggregates OLAP functions Embedded subqueries Subqueries cannot include: ORDER BY clause Unnamed columns
7 Renaming Columns Two techniques are available for renaming columns. For the second technique, the alias list must reference each column. Technique #1 CREATE TABLE emp1 AS (SELECT employee_number AS emp,department_number AS dept,salary_amount AS sal FROM employee) WITH NO DATA; Technique #2 CREATE TABLE emp1 (emp, dept, sal) AS (SELECT employee_number,department_number,salary_amount FROM employee) WITH NO DATA; SHOW TABLE emp1; CREATE SET TABLE SQL00.emp1, FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL (emp INTEGER,,dept INTEGER,sal DECIMAL(10,2)) PRIMARY INDEX ( emp );
8 Changing Column Attributes Column attributes may be altered for the target table. Example 1: Change the column names and the data type of one column. CREATE TABLE dept1 AS (SELECT department_number AS dept,cast(budget_amount AS INTEGER) AS budget FROM department) WITH NO DATA; The following form illustrates how many column attributes are not available from a select statement, so they must be included using this form for alias listing. Note that CAST can be used in the projection. Example 2: Change the column names, attributes and the data types of both columns. CREATE TABLE dept1 ( dept DEFAULT 0 UNIQUE NOT NULL,budget CHECK (budget > 0) ) AS (SELECT CAST(department_number AS INTEGER),CAST(budget_amount AS INTEGER) FROM department) WITH NO DATA;
9 Using Inner Joins in a Subquery Joins may be used in a subquery to copy data from more than one table. Create a table showing the department number, the department name and the name of the department manager. CREATE TABLE dept3 AS (SELECT d.department_number,d.department_name,e.last_name AS mgr_name FROM department d JOIN employee e ON e.employee_number = d.manager_employee_number ) WITH DATA; CREATE SET TABLE DLM.dept3,FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL, CHECKSUM = DEFAULT ( department_number SMALLINT, department_name CHAR(30) CHARACTER SET LATIN NOT CASESPECIFIC, mgr_name CHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC) PRIMARY INDEX ( department_number ); It is important to note that the columns Department_Name and Mgr_Name, from the source tables, are defined as NOT NULL. Use WITH NO DATA to simply build an unpopulated new table.
10 Using Other Joins in a Subquery Many types of joins may be used in a subquery to copy data from more than one table. CREATE TABLE dept3 AS (SELECT d.department_number, d.department_name, e.last_name AS mgr_name FROM department d LEFT JOIN employee e ON e.employee_number = d.manager_employee_number ) WITH DATA; CREATE MULTISET TABLE dept3 AS (SELECT d.department_number, d.department_name, e.last_name AS mgr_name FROM department d CROSS JOIN employee e WITH DATA; CREATE SET TABLE DLM.dept3,FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL, CHECKSUM = DEFAULT ( department_number SMALLINT, department_name CHAR(30) CHARACTER SET LATIN NOT CASESPECIFIC, mgr_name CHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC) PRIMARY INDEX ( department_number ); For these types of joins, whether using WITH DATA or WITH NO DATA, the table definition remains the same. Why is it that WITH DATA is more likely for these two requests than WITH NO DATA? Also note the use of MULTISET in the CROSS JOIN to avoid a possible duplicate row violation.
11 Using Expressions for Columns Calculations and expressions may be used for the columns of the target table. Create and populate a table which shows an employee's number, last name, hire date, birth date and the employee's age at time of hire. CREATE SET TABLE DLM.emp2,FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL, CHECKSUM = DEFAULT ( emp INTEGER, last CHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC, hire DATE FORMAT 'YY/MM/DD', birth DATE FORMAT 'YY/MM/DD', hire_age INTERVAL YEAR(2)) PRIMARY INDEX ( emp ); CREATE TABLE emp2 (emp, last, hire, birth, hire_age) AS (SELECT employee_number,last_name,hire_date,birthdate,(hire_date - birthdate) YEAR FROM employee) WITH DATA; The expression shown gives the difference in the dates as an interval of (a number of) years. Interval Data Types will be discussed in a later module!
12 Using CAST For the example of the previous page, use CAST to change the data type. Note that when using both forms for aliasing in the same request, the alias list technique overrides the projected alias technique (using AS) in the body of the select. CREATE TABLE emp2 (emp, last, hire, birth, hire_age) AS (SELECT employee_number AS Emp, last_name AS LastName, hire_date AS HireDate, birthdate AS BirthDate, CAST((hire_date - birthdate YEAR) AS INT) AS HireAge FROM employee) WITH DATA; CREATE SET TABLE DLM.emp2,FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL, CHECKSUM = DEFAULT ( emp INTEGER, last CHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC, hire DATE FORMAT 'YY/MM/DD', birth DATE FORMAT 'YY/MM/DD', hire_age INTEGER) PRIMARY INDEX ( emp ); As with any data type, this can be CAST to another data type, as shown here.
13 Aliases Having Non-Standard Characters CREATE TABLE "monthly sal 401" AS (SELECT employee_number AS emp,salary_amount/12 AS "Monthly Salary" FROM employee WHERE department_number = 401) WITH DATA; SHOW TABLE "MONTHLY SAL 401" Title stacking only occurs in BTEQ. An example of title stacking is using the notation Monthly//Salary where the // causes Monthly to stack on top of Salary. With Teradata SQL Assistant, the title for "Monthly//Salary" will appear as "Monthly Salary, but must be referenced with the double quotes, as Monthly//Salary. CREATE SET TABLE DLM."monthly sal 401", FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL, CHECKSUM = DEFAULT (emp INTEGER, "Monthly//Salary" DECIMAL(10,2)) PRIMARY INDEX ( emp ); SELECT * FROM "monthly sal 401"
14 Adding Unique and Primary Key Constraints PRIMARY KEY or UNIQUE constraints may be simple methods to use for creating UPIs and USIs. Recall, however, that these both must be defined as NOT NULL. Note, that there is only an alias list (i.e., there is no SELECT). Each alias must match an existing column in order of the CREATE TABLE. SHOW TABLE dept1; CREATE TABLE dept1 (deptno UNIQUE NOT NULL,deptname PRIMARY KEY NOT NULL,budget,manager) AS department WITH NO DATA; CREATE SET TABLE PED1.dept1, FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL (deptno SMALLINT NOT NULL, deptname CHAR(30) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL, budget DECIMAL(10,2), manager INTEGER) UNIQUE PRIMARY INDEX ( deptname ) UNIQUE INDEX ( deptno );
15 Adding Default Values Default values and null attributes may be specified either for WITH DATA or WITH NO DATA table creation. CREATE TABLE dept1 (deptno,budget NOT NULL DEFAULT 0) AS (SELECT department_number,budget_amount FROM department) WITH DATA; SHOW TABLE dept1; Note that the column budget has been defined as NOT NULL and that WITH DATA has been specified. NULLs in the sourcing table column will override the default, causing a failure. CREATE SET TABLE sql00.dept1,no FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL ( deptno SMALLINT, budget DECIMAL(10,2) NOT NULL DEFAULT 0.00 ) PRIMARY INDEX ( deptno ); *** Failure 3604 Cannot place a null value in a NOT NULL field.
16 Populating Default Column Values Population of NOT NULL columns with a DEFAULT value may require special attention. CREATE TABLE dept1 (deptno, budget NOT NULL DEFAULT 0) AS ( SELECT department_number, budget_amount (DEC(10,2)) FROM department ) WITH DATA; Re-write to this: CREATE TABLE dept1 (deptno, budget NOT NULL DEFAULT 0) AS ( SELECT department_number, COALESCE(budget_amount,0) (DEC(10,2)) FROM department) WITH DATA; SELECT * FROM dept1; deptno budget
17 Copying Statistics Statistics may be copied from the sourcing table. Statistics may be propagated from a source table to a target table under certain conditions. (Read the left-hand page for more details) A Generalized form for this construct is: CREATE TABLE NewEmp AS [ tablename (select statement) ] WITH [NO] DATA [ AND [NO] [ STATISTICS STAT[S] ] ]; CREATE TABLE SQL01.Employee AS Employee_Sales.Employee WITH DATA AND STATS; Collect propagates: The specified column definitions and the data associated with those columns. CREATE TABLE SQL01.Employee AS Employee_Sales.Employee WITH NO DATA AND STATS; Collect propagates: The specified column definitions only.
18 Module 1: Summary You can use CREATE TABLE AS to easily create new tables from existing tables. You can specify explicit table attributes for the new table. You can specify explicit column attributes for the new table. You can create a clone or use a subquery to build a new table. You can change SET to MULTISET or FALLBACK to NO FALLBACK. You can propagate statistics to the new table from the sourcing table.
19 Module 1: Review Questions True or False: 1. The default for creating a with CREATE TABLE AS is WITH NO DATA. False - the WITH clause is mandatory. 2. By using CREATE TABLE AS, the new table lasts for only a single query. False the target table is permanent. 3. The following creates a duplicate table of ot, named nt. CREATE TABLE nt AS (SEL * FROM ot) WITH DATA; False - the subquery form does not create a duplicate. 4. You can define a secondary index for the new target table when using the CREATE TABLE AS construct. True 5. You can perform aggregation in the subquery of a CREATE TABLE AS. True 6. A full outer join can be used in the subquery form of CREATE TABLE AS. True 7. You can reference more than one source table in CREATE TABLE AS. True
20 Module 1: Lab Exercise 1) Drop your current Employee tables and then create a copy of the table employee_sales.employee using the subquery form with a SELECT *, populating it with data. Show the definition of it to check primary index. Then perform a SELECT * against it. 2) Use a subquery form to create a table (choose a name), with data, from a left outer join against Employee, Department and Job. Project last name, first name, salary, department name and job description. Verify the results. 3) Using the subquery form of CREATE TABLE AS, create a new Job table and assign the column for hourly billing rate a default of zero. Leave all column names the same as in the Job table. Insert the default hourly billing rate into the new table from the subquery and use the WITH DATA option. Select from the table to confirm the result. Optional: 4) Perform the following and follow it up by selecting from the table and showing the definition. CREATE TABLE y_me AS (SELECT 1 a, 'abc' d, 1e6 j) WITH DATA;
Tables and Volatile Tables
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
More informationTeradata 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 informationSQL Structured Query Language Introduction
SQL Structured Query Language Introduction Rifat Shahriyar Dept of CSE, BUET Tables In relational database systems data are represented using tables (relations). A query issued against the database also
More informationRetrieving 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 informationINDEX. 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 informationAn 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 informationAn 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 informationIBM 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 informationAn 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 informationAn 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 informationGIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement
GIFT Department of Computing Science [Spring 2013] CS-217: Database Systems Lab-2 Manual Data Selection and Filtering using the SELECT Statement V1.0 4/12/2016 Introduction to Lab-2 This lab reinforces
More informationAn 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 informationPASSTCERT 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 informationSlides 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 informationWHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints
SQL KEREM GURBEY WHAT IS SQL Database query language, which can also: Define structure of data Modify data Specify security constraints DATA DEFINITION Data-definition language (DDL) provides commands
More informationRetrieving Data Using the SQL SELECT Statement. Copyright 2009, Oracle. All rights reserved.
Retrieving Data Using the SQL SELECT Statement Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement
More informationChapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Chapter 4 Basic SQL Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries
More informationCOSC 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 informationDatabase Programming with SQL
Database Programming with SQL 2-1 Objectives This lesson covers the following objectives: Apply the concatenation operator to link columns to other columns, arithmetic expressions, or constant values to
More informationIntroduction to SQL. ECE 650 Systems Programming & Engineering Duke University, Spring 2018
Introduction to SQL ECE 650 Systems Programming & Engineering Duke University, Spring 2018 SQL Structured Query Language Major reason for commercial success of relational DBs Became a standard for relational
More informationDatabase Foundations. 6-4 Data Manipulation Language (DML) Copyright 2015, Oracle and/or its affiliates. All rights reserved.
Database Foundations 6-4 Roadmap You are here Introduction to Oracle Application Express Structured Query Language (SQL) Data Definition Language (DDL) Data Manipulation Language (DML) Transaction Control
More informationEGCI 321: Database Systems. Dr. Tanasanee Phienthrakul
1 EGCI 321: Database Systems Dr. Tanasanee Phienthrakul 2 Chapter 10 Data Definition Language (DDL) 3 Basic SQL SQL language Considered one of the major reasons for the commercial success of relational
More informationCopyright 2016 Ramez Elmasri and Shamkant B. Navathe
CHAPTER 6 Basic SQL Slide 6-2 Chapter 6 Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries in SQL INSERT, DELETE, and UPDATE Statements in SQL Additional Features
More informationSQL Server 2008 Tutorial 3: Database Creation
SQL Server 2008 Tutorial 3: Database Creation IT 5101 Introduction to Database Systems J.G. Zheng Fall 2011 DDL Action in SQL Server Creating and modifying structures using the graphical interface Table
More informationMANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)
Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 6 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA
More informationTeradata. 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 informationChapter 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 informationLab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama
The Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Database Lab Lab # 6 Using Subqueries and Set Operators Eng. Alaa O Shama November, 2015 Objectives:
More informationGetting Information from a Table
ch02.fm Page 45 Wednesday, April 14, 1999 2:44 PM Chapter 2 Getting Information from a Table This chapter explains the basic technique of getting the information you want from a table when you do not want
More informationDatabase Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.
Database Foundations 6-3 Roadmap You are here Introduction to Oracle Application Express Structured Query Language (SQL) Data Definition Language (DDL) Data Manipulation Language (DML) Transaction Control
More informationCreating 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 informationDisplaying 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 informationDatabase Management Systems,
Database Management Systems SQL Query Language (1) 1 Topics Introduction SQL History Domain Definition Elementary Domains User-defined Domains Creating Tables Constraint Definition INSERT Query SELECT
More informationD B M G. SQL language: basics. Managing tables. Creating a table Modifying table structure Deleting a table The data dictionary Data integrity
SQL language: basics Creating a table Modifying table structure Deleting a table The data dictionary Data integrity 2013 Politecnico di Torino 1 Creating a table Creating a table (1/3) The following SQL
More informationDeepak Bhinde PGT Comp. Sc.
Deepak Bhinde PGT Comp. Sc. SQL Elements in MySQL Literals: Literals refers to the fixed data value. It may be Numeric or Character. Numeric literals may be integer or real numbers and Character literals
More informationIntermediate SQL: Aggregated Data, Joins and Set Operators
Intermediate SQL: Aggregated Data, Joins and Set Operators Aggregated Data and Sorting Objectives After completing this lesson, you should be able to do the following: Identify the available group functions
More informationBasic 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 informationJoin, 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 informationObjectives. 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 informationIntroduction. Sample Database SQL-92. Sample Data. Sample Data. Chapter 6 Introduction to Structured Query Language (SQL)
Chapter 6 Introduction to Structured Query Language (SQL) Introduction Structured Query Language (SQL) is a data sublanguage that has constructs for defining and processing a database It can be Used stand-alone
More informationIBM 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 informationOracle Database SQL Basics
Oracle Database SQL Basics Kerepes Tamás, Webváltó Kft. tamas.kerepes@webvalto.hu 2015. február 26. Copyright 2004, Oracle. All rights reserved. SQL a history in brief The relational database stores data
More informationDownloaded 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 informationOracle 1Z MySQL 5.6 Developer.
Oracle 1Z0-882 MySQL 5.6 Developer http://killexams.com/exam-detail/1z0-882 SELECT... WHERE DATEDIFF (dateline, 2013-01-01 ) = 0 C. Use numeric equivalents for comparing the two dates: SELECT...WHERE MOD(UNIX_TIMESTAMP
More informationCOSC344 Database Theory and Applications. Lecture 6 SQL Data Manipulation Language (1)
COSC344 Database Theory and Applications Lecture 6 SQL Data Manipulation Language (1) COSC344 Lecture 56 1 Overview Last Lecture SQL - DDL This Lecture SQL - DML INSERT DELETE (simple) UPDATE (simple)
More informationBased 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 informationCreating 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 informationCS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen
CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 10: INTRODUCTION TO SQL FULL RELATIONAL OPERATIONS MODIFICATION LANGUAGE Union, Intersection, Differences (select
More informationStructured Query Language (SQL)
Structured Query Language (SQL) SQL Chapters 6 & 7 (7 th edition) Chapters 4 & 5 (6 th edition) PostgreSQL on acsmysql1.acs.uwinnipeg.ca Each student has a userid and initial password acs!
More informationConstraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2
CMPT 354 Constraints Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers John Edgar 2 firstname type balance city customerid lastname accnumber rate branchname phone
More informationÇALIŞMA TEST SORULARI
1. A table has the following definition: EMPLOYEES( EMPLOYEE_ID NUMBER(6) NOT NULL, LAST_NAME VARCHAR2(10) NOT NULL, MANAGER_ID VARCHAR2(6)) and contains the following rows: (1001, 'Bob Bevan', '200')
More informationchapter 2 G ETTING I NFORMATION FROM A TABLE
chapter 2 Chapter G ETTING I NFORMATION FROM A TABLE This chapter explains the basic technique for getting the information you want from a table when you do not want to make any changes to the data and
More informationChapter 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 informationTeradata SQL Class Outline
Teradata SQL 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: Thomas
More informationPrinciples 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 informationCIS Slightly-different version of Week 10 Lab, also intro to SQL UPDATE and DELETE, and more
CIS 315 - Week 10 Lab Exercise p. 1 Sources: CIS 315 - Slightly-different version of Week 10 Lab, 10-27-09 more SELECT operations: UNION, INTERSECT, and MINUS, also intro to SQL UPDATE and DELETE, and
More informationRetrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved.
Retrieving Data Using the SQL SELECT Statement Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL
More informationSQL 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 informationGIFT 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 informationAssignment 6: SQL III Solution
Data Modelling and Databases Exercise dates: April 12/April 13, 2018 Ce Zhang, Gustavo Alonso Last update: April 16, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 6: SQL III Solution This assignment
More informationCSE 530A SQL. Washington University Fall 2013
CSE 530A SQL Washington University Fall 2013 SELECT SELECT * FROM employee; employee_id last_name first_name department salary -------------+-----------+------------+-----------------+-------- 12345 Bunny
More informationDatabase Management Systems,
Database Management Systems SQL Query Language (2) 1 Topics Update Query Delete Query Integrity Constraint Cascade Deletes Deleting a Table Join in Queries Table variables More Options in Select Queries
More informationSYSTEM 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 information1 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 informationData Manipulation Language (DML)
In the name of Allah Islamic University of Gaza Faculty of Engineering Computer Engineering Department ECOM 4113 DataBase Lab Lab # 3 Data Manipulation Language (DML) El-masry 2013 Objective To be familiar
More informationUsing the Set Operators. Copyright 2006, Oracle. All rights reserved.
Using the Set Operators Objectives After completing this lesson, you should be able to do the following: Describe set operators Use a set operator to combine multiple queries into a single query Control
More informationOuter 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 informationUnit 1 - Chapter 4,5
Unit 1 - Chapter 4,5 CREATE DATABASE DatabaseName; SHOW DATABASES; USE DatabaseName; DROP DATABASE DatabaseName; CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype,... columnn
More informationBasic SQL. Dr Fawaz Alarfaj. ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation
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 MIDTERM EXAM 2 Basic
More informationExam 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 informationCSC Web Programming. Introduction to SQL
CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with
More informationGIFT 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 informationAdvance Database Systems. Joining Concepts in Advanced SQL Lecture# 4
Advance Database Systems Joining Concepts in Advanced SQL Lecture# 4 Lecture 4: Joining Concepts in Advanced SQL Join Cross Join Inner Join Outer Join 3 Join 4 Join A SQL join clause combines records from
More informationCreating 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 informationFull file at
SQL for SQL Server 1 True/False Questions Chapter 2 Creating Tables and Indexes 1. In order to create a table, three pieces of information must be determined: (1) the table name, (2) the column names,
More informationIBM DB2 UDB V7.1 Family Fundamentals.
IBM 000-512 DB2 UDB V7.1 Family Fundamentals http://killexams.com/exam-detail/000-512 Answer: E QUESTION: 98 Given the following: A table containing a list of all seats on an airplane. A seat consists
More informationORACLE 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 information1 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 informationUsing DDL Statements to Create and Manage Tables. Copyright 2004, Oracle. All rights reserved.
Using DDL Statements to Create and Manage Tables Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Categorize the main database
More informationTrigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired.
Aim:- TRIGGERS Trigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired. Advantages of database triggers: ---> Data is generated
More informationMore 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 informationCSCB20 Week 3. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017
CSCB20 Week 3 Introduction to Database and Web Application Programming Anna Bretscher Winter 2017 This Week Intro to SQL and MySQL Mapping Relational Algebra to SQL queries We will focus on queries to
More informationChapter 9: Working with MySQL
Chapter 9: Working with MySQL Informatics Practices Class XI (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra, PGT (Comp.Sc.) Kendriya
More informationEXISTS 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 informationDatabase design process
Database technology Lecture 2: Relational databases and SQL Jose M. Peña jose.m.pena@liu.se Database design process 1 Relational model concepts... Attributes... EMPLOYEE FNAME M LNAME SSN BDATE ADDRESS
More informationT-SQL Training: T-SQL for SQL Server for Developers
Duration: 3 days T-SQL Training Overview T-SQL for SQL Server for Developers training teaches developers all the Transact-SQL skills they need to develop queries and views, and manipulate data in a SQL
More informationSQL. Rodrigo García Carmona Universidad San Pablo-CEU Escuela Politécnica Superior
SQL Rodrigo García Carmona Universidad San Pablo-CEU Escuela Politécnica Superior 1 DDL 2 DATA TYPES All columns must have a data type. The most common data types in SQL are: Alphanumeric: Fixed length:
More informationVisit 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 information1) Introduction to SQL
1) Introduction to SQL a) Database language enables users to: i) Create the database and relation structure; ii) Perform insertion, modification and deletion of data from the relationship; and iii) Perform
More informationCarnegie Mellon Univ. Dept. of Computer Science Database Applications. General Overview - rel. model. Overview - detailed - SQL
Faloutsos 15-415 Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications C. Faloutsos Lecture#7 (cont d): Rel. model - SQL part3 General Overview - rel. model Formal query languages
More informationUsing DDL Statements to Create and Manage Tables. Copyright 2004, Oracle. All rights reserved.
Using DDL Statements to Create and Manage Tables Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Categorize the main database
More informationMTA Database Administrator Fundamentals Course
MTA Database Administrator Fundamentals Course Session 1 Section A: Database Tables Tables Representing Data with Tables SQL Server Management Studio Section B: Database Relationships Flat File Databases
More informationSQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas
SQL SQL Functionality stands for Structured Query Language sometimes pronounced sequel a very-high-level (declarative) language user specifies what is wanted, not how to find it number of standards original
More informationLab # 6. Data Manipulation Language (DML)
Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Lab # 6 Data Manipulation Language (DML) Eng. Haneen El-Masry December, 2014 2 Objective To be more familiar
More informationUsing DDL Statements to Create and Manage Tables. Copyright 2006, Oracle. All rights reserved.
Using DDL Statements to Create and Manage Tables Objectives After completing this lesson, you should be able to do the following: Categorize the main database objects Review the table structure List the
More informationQuerying Data with Transact SQL
Course 20761A: Querying Data with Transact SQL Course details Course Outline Module 1: Introduction to Microsoft SQL Server 2016 This module introduces SQL Server, the versions of SQL Server, including
More informationTable Joins and Indexes in SQL
Table Joins and Indexes in SQL Based on CBSE Curriculum Class -11 By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region Neha Tyagi, PGT CS II Shift Jaipur Introduction Sometimes we need an information
More informationSchool of Computing and Information Technology. Examination Paper Autumn Session 2017
School of Computing and Information Technology CSIT115 Data Management and Security Wollongong Campus Student to complete: Family name Other names Student number Table number Examination Paper Autumn Session
More informationCS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen
CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 9: INTRODUCTION TO SQL SELECT-FROM-WHERE STATEMENTS SUBQUERIES Set-up the database 1. Log in to your machine using
More information1Z0-007 ineroduction to oracle9l:sql
ineroduction to oracle9l:sql Q&A DEMO Version Copyright (c) 2007 Chinatag LLC. All rights reserved. Important Note Please Read Carefully For demonstration purpose only, this free version Chinatag study
More information