SQL Workshop. Introduction Queries. Doug Shook
|
|
- Tamsin Stone
- 6 years ago
- Views:
Transcription
1 SQL Workshop Introduction Queries Doug Shook
2 SQL Server As its name implies: its a data base server! Technically it is a database management system (DBMS) Competitors: Oracle, MySQL, DB2 End users (that s you!) interact as clients Queries formed on the client and passed to the server 2
3 SQL Server Database server ` Network ` Client Client ` Client 3
4 Relational database model Data is stored in tables One or more columns (fields) Many, many, rows (records) Modeled after real world entities Attributes Instances Primary keys are used to identify each record Must be unique! 4
5 Relational database model Primary key Columns Rows 5
6 Relational database model Relationships are defined between two tables by foreign keys One-to-one One-to-many Many-to-many Primary key -> foreign key 6
7 Relational database model Primary key Foreign key 7
8 Columns Columns have associated properties Data type Null? Default value Identity column 8
9 Comparison with file systems Databases... Are consistent Same basic structure for all data Are easier to maintain Due to centralization Can perform validations Can enforce relationships Can access many records at once Allow concurrent access Performance considerations? 9
10 SQL Forms the basis of all DBMS Basic statements will work (mostly) regardless of platform Each vendor adds extensions Two main categories Data Manipulation Language Data Definition Language 10
11 SQL SQL DML statements SELECT INSERT UPDATE DELETE SQL DDL statements CREATE DATABASE, TABLE, INDEX ALTER TABLE, INDEX DROP DATABASE, TABLE, INDEX 11
12 SQL Coding Guidelines Freeform Lines, spaces, linebreaks do not affect code Not case sensitive (!) Comments Block /* */ Single line -- 12
13 SQL Coding Guidelines Recommendations: Each clause should be on a new line Break up long clauses and indent Keywords should be capatalized (or in all caps) Column and table names should use CamelCase Each statement should end with a semicolon Technically not required by SQL Server but... 13
14 SQL Coding Guidelines A SELECT statement that s difficult to read select invoicenumber, invoicedate, invoicetotal, invoicetotal paymenttotal credittotal as balancedue from invoices where invoicetotal paymenttotal credittotal > 0 order by invoicedate A SELECT statement that s coded with a readable style Select InvoiceNumber, InvoiceDate, InvoiceTotal, InvoiceTotal PaymentTotal CreditTotal As BalanceDue From Invoices Where InvoiceTotal PaymentTotal CreditTotal > 0 Order By InvoiceDate; 14
15 Our Setup Server set up for us We'll be sharing...so be nice! Need a client DBVisualizer 15
16 Connecting to the DB Server name: supplied to you Authentication Username: washu Password: workshop 16
17 Database Diagrams Shows: Table relationships Column names Primary keys Great for visualizing the database as a whole 17
18 Queries Click the green triangle SQL Commander Ensure that the DB you d like to work with is selected in the combobox Type in the query Execute button Results displayed at the bottom Once a query works the way you want, save it! 18
19 Syntax Errors Sometimes detected by the query editor Common mistakes Wrong DB selected in combobox Misspellings Missing quotation/parentheses 19
20 Documentation Short version: Use it! Long version: It will save you time and effort. Use it! 20
21 SELECT Used to retrieve information (Up to) four clauses: SELECT Column name(s) FROM Table name WHERE (Optional) Conditional statement(s) ORDER BY (Optional) Column name(s) 21
22 SELECT Examples A simple SELECT statement SELECT * FROM Invoices; A SELECT statement that retrieves and sorts rows SELECT InvoiceNumber, InvoiceDate, InvoiceTotal FROM Invoices ORDER BY InvoiceTotal; A SELECT statement that retrieves a calculated value SELECT InvoiceID, InvoiceTotal, CreditTotal + PaymentTotal AS TotalCredits FROM Invoices WHERE InvoiceID = 17; A SELECT statement that retrieves all invoices between given dates SELECT InvoiceNumber, InvoiceDate, InvoiceTotal FROM Invoices WHERE InvoiceDate BETWEEN ' ' AND ' ' ORDER BY InvoiceDate; 22
23 Column Specifications The expanded syntax of the SELECT clause SELECT [ALL DISTINCT] [TOP n [PERCENT] [WITH TIES]] column_specification [[AS] result_column] [, column_specification [[AS] result_column]]... Five ways to code column specifications All columns in a base table Column name in a base table Arithmetic expression String expression Function 23
24 Column Specifications Column specifications that use base table values The * is used to retrieve all columns SELECT * Column names are used to retrieve specific columns SELECT VendorName, VendorCity, VendorState Column specifications that use calculated values An arithmetic expression is used to calculate BalanceDue SELECT InvoiceNumber, InvoiceTotal - PaymentTotal CreditTotal AS BalanceDue A string expression is used to calculate FullName SELECT VendorContactFName + ' ' + VendorContactLName AS FullName A function is used to calculate CurrentDate SELECT InvoiceNumber, InvoiceDate, GETDATE() AS CurrentDate 24
25 Naming Columns Two ways to name the columns in a result set Using the AS keyword (the preferred technique) SELECT InvoiceNumber AS [Invoice Number], InvoiceDate AS Date, InvoiceTotal AS Total FROM Invoices; Using the equal operator (an older technique) SELECT [Invoice Number] = InvoiceNumber, Date = InvoiceDate, Total = InvoiceTotal FROM Invoices; The result set for both SELECT statements 25
26 String Expressions How to concatenate string data SELECT VendorCity, VendorState, VendorCity + VendorState FROM Vendors; How to format string data using literal values SELECT VendorName, VendorCity + ', ' + VendorState + ' ' + VendorZipCode AS Address FROM Vendors; How to include apostrophes in literal values SELECT VendorName + '''s Address: ', VendorCity + ', ' + VendorState + ' ' + VendorZipCode FROM Vendors; 26
27 Functions A SELECT statement that uses the LEFT function SELECT VendorContactFName, VendorContactLName, LEFT(VendorContactFName, 1) + LEFT(VendorContactLName, 1) AS Initials FROM Vendors; A SELECT statement that uses the CONVERT function SELECT 'Invoice: #' + InvoiceNumber + ', dated ' + CONVERT(char(8), PaymentDate, 1) + ' for $' + CONVERT(varchar(9), PaymentTotal, 1) FROM Invoices; A SELECT statement that computes the age of an invoice SELECT InvoiceDate, GETDATE() AS 'Today''s Date', DATEDIFF(day, InvoiceDate, GETDATE()) AS Age FROM Invoices; 27
28 DISTINCT A SELECT statement that returns all rows SELECT VendorCity, VendorState FROM Vendors ORDER BY VendorCity; A SELECT statement that eliminates duplicate rows SELECT DISTINCT VendorCity, VendorState FROM Vendors; 28
29 TOP A SELECT statement with a TOP clause SELECT TOP 5 VendorID, InvoiceTotal FROM Invoices ORDER BY InvoiceTotal DESC; A SELECT statement with a TOP clause and the PERCENT keyword SELECT TOP 5 PERCENT VendorID, InvoiceTotal FROM Invoices ORDER BY InvoiceTotal DESC; A SELECT statement with a TOP clause and the WITH TIES keyword SELECT TOP 5 WITH TIES VendorID, InvoiceDate FROM Invoices ORDER BY InvoiceDate ASC; 29
30 WHERE Recall that this is optional! Examples of WHERE clauses that retrieve Vendors located in Iowa WHERE VendorState = 'IA' Invoices with a balance due (two variations) WHERE InvoiceTotal PaymentTotal CreditTotal > 0 WHERE InvoiceTotal > PaymentTotal + CreditTotal Vendors with names from A to L WHERE VendorName < 'M' Invoices on or before a specified date WHERE InvoiceDate <= ' ' Invoices on or after a specified date WHERE InvoiceDate >= '5/1/12' Invoices with credits that don t equal zero WHERE CreditTotal <> 0 30
31 Logical Operators The syntax of the WHERE clause with logical operators WHERE [NOT] search_condition_1 {AND OR} [NOT] search_condition_2... Examples of queries using logical operators The AND operator WHERE VendorState = 'NJ' AND YTDPurchases > 200 The OR operator WHERE VendorState = 'NJ' OR YTDPurchases > 200 The NOT operator WHERE NOT (InvoiceTotal >= 5000 OR NOT InvoiceDate <= ' ') The same condition without the NOT operator WHERE InvoiceTotal < 5000 AND InvoiceDate <= ' ' 31
32 IN The syntax of the WHERE clause with an IN phrase WHERE test_expression [NOT] IN ({subquery expression_1 [, expression_2]...}) Examples of the IN phrase An IN phrase with a list of numeric literals WHERE TermsID IN (1, 3, 4) An IN phrase preceded by NOT WHERE VendorState NOT IN ('CA', 'NV', 'OR') An IN phrase with a subquery WHERE VendorID IN (SELECT VendorID FROM Invoices WHERE InvoiceDate = ' ') 32
33 BETWEEN The syntax of the WHERE clause with a BETWEEN phrase WHERE test_expression [NOT] BETWEEN begin_expression AND end_expression Examples of the BETWEEN phrase A BETWEEN phrase with literal values WHERE InvoiceDate BETWEEN ' ' AND ' ' A BETWEEN phrase preceded by NOT WHERE VendorZipCode NOT BETWEEN AND A BETWEEN phrase with a test expression coded as a calculated value WHERE InvoiceTotal PaymentTotal CreditTotal BETWEEN 200 AND 500 A BETWEEN phrase with calculated values WHERE InvoiceDueDate BETWEEN GetDate() AND GetDate()
34 Dates Datetime data type includes date and time (duh) So what happens when you compare just the date to a datetime column? More about dates to come... 34
35 LIKE Used for matching string patterns Symbols %: match zero or more characters _: match any single character []: match anything contained within [ - ]: match anything within the given range [ ^ ]: match anything except what is given 35
36 LIKE WHERE clauses that use the LIKE phrase Example 1 WHERE VendorCity LIKE 'SAN%' Cities that will be retrieved San Diego and Santa Ana Example 2 WHERE VendorName LIKE 'COMPU_ER%' Vendors that will be retrieved Compuserve and Computerworld Example 3 WHERE VendorContactLName LIKE 'DAMI[EO]N' Names that will be retrieved Damien and Damion 36
37 LIKE WHERE clauses that use the LIKE phrase (cont.) Example 4 WHERE VendorState LIKE 'N[A-J]' States that will be retrieved NC and NJ but not NV or NY Example 5 WHERE VendorState LIKE 'N[^K-Y]' States that will be retrieved NC and NJ but not NV or NY Example 6 WHERE VendorZipCode NOT LIKE '[1-9]%' Zip codes that will be retrieved and
38 NULL What qualifies as NULL? 0? Empty string? ( ) A single space? ( ) 38
39 NULL A SELECT statement that retrieves rows with zero values SELECT * FROM NullSample WHERE InvoiceTotal = 0; A SELECT statement that retrieves rows with non-zero values SELECT * FROM NullSample WHERE InvoiceTotal <> 0; A SELECT statement that retrieves rows with null values SELECT * FROM NullSample WHERE InvoiceTotal IS NULL; A SELECT statement that retrieves rows without null values SELECT * FROM NullSample WHERE InvoiceTotal IS NOT NULL; 39
40 ORDER BY Can sort by one or more columns Sorts ascending by default Sorting order (ascending) Null Special Characters (&,!, etc.) Numbers Letters Can also use aliases, expressions, and column positions 40
41 ORDER BY An ORDER BY clause that sorts by one column in descending sequence SELECT VendorName, VendorCity + ', ' + VendorState + ' ' + VendorZipCode AS Address FROM Vendors ORDER BY VendorName DESC; An ORDER BY clause that sorts by three columns SELECT VendorName, VendorCity + ', ' + VendorState + ' ' + VendorZipCode AS Address FROM Vendors ORDER BY VendorState, VendorCity, VendorName; 41
42 ORDER BY An ORDER BY clause that uses an alias SELECT VendorName, VendorCity + ', ' + VendorState + ' ' + VendorZipCode AS Address FROM Vendors ORDER BY Address, VendorName; An ORDER BY clause that uses an expression SELECT VendorName, VendorCity + ', ' + VendorState + ' ' + VendorZipCode AS Address FROM Vendors ORDER BY VendorContactLName + VendorContactFName; An ORDER BY clause that uses column positions SELECT VendorName, VendorCity + ', ' + VendorState + ' ' + VendorZipCode AS Address FROM Vendors ORDER BY 2, 1; 42
43 ORDER BY OFFSET and FETCH can optionally be used to retrieve a range of rows OFFSET: Starting position FETCH: Number to retrieve after offset 43
44 ORDER BY The syntax of the ORDER BY clause for retrieving a range of rows ORDER BY order_by_list OFFSET offset_row_count {ROW ROWS} [FETCH {FIRST NEXT} fetch_row_count {ROW ROWS} ONLY] An ORDER BY clause that retrieves the first five rows SELECT VendorID, InvoiceTotal FROM Invoices ORDER BY InvoiceTotal DESC OFFSET 0 ROWS FETCH FIRST 5 ROWS ONLY; An ORDER BY clause that retrieves rows 11 through 20 SELECT VendorName, VendorCity, VendorState, VendorZipCode FROM Vendors WHERE VendorState = 'CA' ORDER BY VendorCity OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY; 44
45 45 Exercises Write a SELECT statement that returns three columns from the Vendors table: VendorContactFName, VendorContactLName, and VendorName. Sort the result set by last name, then by first name.
46 46 Exercises Write a SELECT statement that returns four columns from the Invoices table, named Number, Total, Credits, and Balance: Number Column alias for the InvoiceNumber column Total Column alias for the InvoiceTotal column Credits Sum of the PaymentTotal and CreditTotal columns Balance InvoiceTotal minus the sum of PaymentTotal and CreditTotal
47 47 Exercises Write a SELECT statement that returns one column from the Vendors table named Full Name. Create this column from the VendorContactFName and VendorContactLName columns. Format it as follows: last name, comma, first name (for example, "Doe, John"). Sort the result set by last name, then by first name.
48 48 Exercises Write a SELECT statement that returns three columns: InvoiceTotal From the Invoices table 10% 10% of the value of InvoiceTotal Plus 10% The value of InvoiceTotal plus 10% Only return those rows with a balance due greater than Sort the result set by InvoiceTotal, with the largest invoice first.
49 49 Exercises Modify the solution to the problem on slide 51 to filter for invoices with an InvoiceTotal that's greater than or equal to $500 but less than or equal to $10,000.
50 50 Exercises Modify the solution to the problem on slide 52 to filter for contacts whose last name begins with the letter A, B, C, or E.
51 51 Exercises Write a SELECT statement that determines whether the PaymentDate column of the Invoices table has any invalid values. To be valid, PaymentDate must be a null value if there's a balance due and a non-null value if there's no balance due. Code a compound condition in the WHERE clause that tests for these conditions.
HNDIT 1105 Database Management Systems
HNDIT 1105 Database Management Systems How to retrieve data in a single table By S. Sabraz Nawaz M.Sc. In IS (SLIIT), PGD in IS (SLIIT), BBA (Hons.) Spl. in IS (SEUSL), MIEEE, MAIS Senior Lecturer in MIT
More informationChapter 3 How to retrieve data from a single table
Chapter 3 How to retrieve data from a single table Murach's MySQL, C3 2015, Mike Murach & Associates, Inc. Slide 1 Objectives Applied Code SELECT statements that require any of the language elements presented
More informationDatabase Management Systems
Database Management Systems Design and Creation Doug Shook Database Creation Design is very important Long lasting implications How is our data being stored again? How do we manipulate data? 2 Example
More informationSQL Workshop. Joins. Doug Shook
SQL Workshop Joins Doug Shook Inner Joins Joins are used to combine data from multiple tables into one result Requires the name of the column from the second table, along with a condition that defines
More informationLesson 05: How to Insert, Update, and Delete Data. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL
Lesson 05: How to Insert, Update, and Delete Data By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL The syntax of the INSERT statement INSERT [INTO] table_name [(column_list)] [DEFAULT] VALUES (expression_1
More informationChapter 7 How to code subqueries
Chapter 7 How to code subqueries Murach's MySQL, C7 2015, Mike Murach & Associates, Inc. Slide 1 Objectives Applied Code SELECT statements that require subqueries. Knowledge Describe the way subqueries
More informationSQL Workshop. Database Design. Doug Shook
SQL Workshop Database Design Doug Shook Data Structure Design Real-world system Database system People Tables Documents Facilities Columns Other systems Rows 2 Data Structure Design Relational database
More informationSQL Workshop. Subqueries. Doug Shook
SQL Workshop Subqueries Doug Shook Subqueries A SELECT statement within a SELECT statement Four ways to code one: WHERE (*) HAVING (*) FROM SELECT Syntax is the same Rare to see GROUP BY or HAVING 2 Subqueries
More informationChapter 1 An introduction to relational databases and SQL
Chapter 1 An introduction to relational databases and SQL Murach's MySQL, C1 2015, Mike Murach & Associates, Inc. Slide 1 Objectives Knowledge Identify the three main hardware components of a client/server
More informationLecture 3: Continuing SQL. Monday, February 2, 2015
Lecture 3: Continuing SQL Monday, February 2, 2015 1 Announcements Homework #1 has been posted on Canvas and is due by 4pm next Monday FoCS Career Night this Wednesday from 5:00 pm to 7:30 pm CNS Spring
More informationChapter 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 informationChapter 11 How to create databases, tables, and indexes
Chapter 11 How to create databases, tables, and indexes Murach's MySQL, C11 2015, Mike Murach & Associates, Inc. Slide 1 Objectives Applied Given the design for a database, write the DDL statements to
More informationSQL Workshop. Summaries. Doug Shook
SQL Workshop Summaries Doug Shook Aggregates Also called column functions AVG, SUM, MIN, MAX, COUNT Will use all values can use distinct if desired All except COUNT ignore null values A summary query that
More informationChapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel
Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel 1 In this chapter, you will learn: The basic commands
More informationDatabase Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and
More informationRelational Database Management Systems for Epidemiologists: SQL Part I
Relational Database Management Systems for Epidemiologists: SQL Part I Outline SQL Basics Retrieving Data from a Table Operators and Functions What is SQL? SQL is the standard programming language to create,
More informationSQL functions fit into two broad categories: Data definition language Data manipulation language
Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition Chapter 7 Beginning Structured Query Language (SQL) MDM NUR RAZIA BINTI MOHD SURADI 019-3932846 razia@unisel.edu.my
More information1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data
1 Writing Basic SQL SELECT Statements Objectives 1-2 Capabilities of SQL SELECT Statements 1-3 Basic SELECT Statement 1-4 Selecting All Columns 1-5 Selecting Specific Columns 1-6 Writing SQL Statements
More informationLecture 9: Database Design. Wednesday, February 18, 2015
Lecture 9: Database Design Wednesday, February 18, 2015 Agenda Review HW #2 Discuss Normalization Theory Take Quiz #3 Normal Forms 1st Normal Form (1NF): will discuss briefly 2nd Normal Form (2NF): will
More informationHomework Assignment. 1. Stored Procedures (SPs)
Homework Assignment In this homework, you will practice how to create database objects such as stored procedures, stored functions, triggers, and events. 1. Stored Procedures (SPs) Stored procedure is
More informationConceptual Design. The Entity-Relationship (ER) Model
Conceptual Design. The Entity-Relationship (ER) Model CS430/630 Lecture 12 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Relationship Set Representation ssn name lot since
More informationOracle Syllabus Course code-r10605 SQL
Oracle Syllabus Course code-r10605 SQL Writing Basic SQL SELECT Statements Basic SELECT Statement Selecting All Columns Selecting Specific Columns Writing SQL Statements Column Heading Defaults Arithmetic
More informationMIT Database Management Systems
MIT 22033 Database Management Systems Lesson 04: How to retrieve data from two or more tables By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL How to code an inner join A join is used to combine columns
More informationOracle Database 11g: SQL and PL/SQL Fundamentals
Oracle University Contact Us: +33 (0) 1 57 60 20 81 Oracle Database 11g: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn In this course, students learn the fundamentals of SQL and PL/SQL
More informationOracle Database: SQL and PL/SQL Fundamentals NEW
Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training delivers the fundamentals of SQL and PL/SQL along with the
More informationOracle Database: SQL and PL/SQL Fundamentals Ed 2
Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Oracle Database: SQL and PL/SQL Fundamentals Ed 2 Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals
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 informationOracle SQL. murach s. and PL/SQL TRAINING & REFERENCE. (Chapter 2)
TRAINING & REFERENCE murach s Oracle SQL and PL/SQL (Chapter 2) works with all versions through 11g Thanks for reviewing this chapter from Murach s Oracle SQL and PL/SQL. To see the expanded table of contents
More informationChapter 8 How to work with data types
Chapter 8 How to work with data types Murach's MySQL, C8 2015, Mike Murach & Associates, Inc. Slide 1 Objectives Applied Code queries that convert data from one data type to another. Knowledge Describe
More informationDB2 SQL Class Outline
DB2 SQL Class Outline The Basics of SQL Introduction Finding Your Current Schema Setting Your Default SCHEMA SELECT * (All Columns) in a Table SELECT Specific Columns in a Table Commas in the Front or
More informationFull file at
David Kroenke's Database Processing: Fundamentals, Design and Implementation (10 th Edition) CHAPTER TWO INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) True-False Questions 1. SQL stands for Standard
More informationTable of Contents. PDF created with FinePrint pdffactory Pro trial version
Table of Contents Course Description The SQL Course covers relational database principles and Oracle concepts, writing basic SQL statements, restricting and sorting data, and using single-row functions.
More informationYou can write a command to retrieve specified columns and all rows from a table, as illustrated
CHAPTER 4 S I N G L E - TA BL E QUERIES LEARNING OBJECTIVES Objectives Retrieve data from a database using SQL commands Use simple and compound conditions in queries Use the BETWEEN, LIKE, and IN operators
More informationOracle Database: Introduction to SQL Ed 2
Oracle University Contact Us: +40 21 3678820 Oracle Database: Introduction to SQL Ed 2 Duration: 5 Days What you will learn This Oracle Database 12c: Introduction to SQL training helps you write subqueries,
More information12. MS Access Tables, Relationships, and Queries
12. MS Access Tables, Relationships, and Queries 12.1 Creating Tables and Relationships Suppose we want to build a database to hold the information for computers (also refer to parts in the text) and suppliers
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 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 informationSQL Interview Questions
SQL Interview Questions SQL stands for Structured Query Language. It is used as a programming language for querying Relational Database Management Systems. In this tutorial, we shall go through the basic
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 informationOracle Database 10g: Introduction to SQL
ORACLE UNIVERSITY CONTACT US: 00 9714 390 9000 Oracle Database 10g: Introduction to SQL Duration: 5 Days What you will learn This course offers students an introduction to Oracle Database 10g database
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 informationGreenplum SQL Class Outline
Greenplum SQL Class Outline The Basics of Greenplum SQL Introduction SELECT * (All Columns) in a Table Fully Qualifying a Database, Schema and Table SELECT Specific Columns in a Table Commas in the Front
More information2) SQL includes a data definition language, a data manipulation language, and SQL/Persistent stored modules. Answer: TRUE Diff: 2 Page Ref: 36
Database Processing, 12e (Kroenke/Auer) Chapter 2: Introduction to Structured Query Language (SQL) 1) SQL stands for Standard Query Language. Diff: 1 Page Ref: 32 2) SQL includes a data definition language,
More informationII. Structured Query Language (SQL)
II. Structured Query Language (SQL) Lecture Topics ffl Basic concepts and operations of the relational model. ffl The relational algebra. ffl The SQL query language. CS448/648 II - 1 Basic Relational Concepts
More informationChapter-14 SQL COMMANDS
Chapter-14 SQL COMMANDS What is SQL? Structured Query Language and it helps to make practice on SQL commands which provides immediate results. SQL is Structured Query Language, which is a computer language
More informationII. Structured Query Language (SQL)
II. Structured Query Language () Lecture Topics Basic concepts and operations of the relational model. The relational algebra. The query language. CS448/648 1 Basic Relational Concepts Relating to descriptions
More informationData Infrastructure IRAP Training 6/27/2016
Data Infrastructure IRAP Training 6/27/2016 UCDW Database Models Integrity Constraints Training Database SQL Defined Types of SQL Languages SQL Basics Simple SELECT SELECT with Aliases SELECT with Conditions/Rules
More informationKen s SQL Syntax Refresher
Ken s SQL Syntax Refresher 27Apr10 Ken s SQL Syntax Refresher 1 Select SELECT [ * ALL DISTINCT column1, column2 ] FROM table1 [, table2 ]; SELECT [ * ALL DISTINCT column1, column2 ] FROM table1 [, table2
More information5. Single-row function
1. 2. Introduction Oracle 11g Oracle 11g Application Server Oracle database Relational and Object Relational Database Management system Oracle internet platform System Development Life cycle 3. Writing
More informationCGS 3066: Spring 2017 SQL Reference
CGS 3066: Spring 2017 SQL Reference Can also be used as a study guide. Only covers topics discussed in class. This is by no means a complete guide to SQL. Database accounts are being set up for all students
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 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 informationTest Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke
Test Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke Link full download: https://testbankservice.com/download/test-bank-fordatabase-processing-fundamentals-design-and-implementation-13th-edition-bykroenke
More informationIn This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL
In This Lecture Yet More SQL Database Systems Lecture 9 Natasha Alechina Yet more SQL ORDER BY Aggregate functions and HAVING etc. For more information Connoly and Begg Chapter 5 Ullman and Widom Chapter
More informationLanguage. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq
Language f SQL Larry Rockoff Course Technology PTR A part ofcenqaqe Learninq *, COURSE TECHNOLOGY!» CENGAGE Learning- Australia Brazil Japan Korea Mexico Singapore Spain United Kingdom United States '
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 informationLecture 06. Fall 2018 Borough of Manhattan Community College
Lecture 06 Fall 2018 Borough of Manhattan Community College 1 Introduction to SQL Over the last few years, Structured Query Language (SQL) has become the standard relational database language. More than
More informationChapter # 7 Introduction to Structured Query Language (SQL) Part I
Chapter # 7 Introduction to Structured Query Language (SQL) Part I Introduction to SQL SQL functions fit into two broad categories: Data definition language Data manipulation language Basic command set
More informationLesson 2. Data Manipulation Language
Lesson 2 Data Manipulation Language IN THIS LESSON YOU WILL LEARN To add data to the database. To remove data. To update existing data. To retrieve the information from the database that fulfil the stablished
More informationEE221 Databases Practicals Manual
EE221 Databases Practicals Manual Lab 1 An Introduction to SQL Lab 2 Database Creation and Querying using SQL Assignment Data Analysis, Database Design, Implementation and Relation Normalisation School
More informationWHAT IS A DATABASE? There are at least six commonly known database types: flat, hierarchical, network, relational, dimensional, and object.
1 WHAT IS A DATABASE? A database is any organized collection of data that fulfills some purpose. As weather researchers, you will often have to access and evaluate large amounts of weather data, and this
More informationRETRIEVING DATA USING THE SQL SELECT STATEMENT
RETRIEVING DATA USING THE SQL SELECT STATEMENT Course Objectives List the capabilities of SQL SELECT statements Execute a basic SELECT statement Development Environments for SQL Lesson Agenda Basic SELECT
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 informationOracle Database 10g: SQL Fundamentals I
Oracle Database 10g: SQL Fundamentals I Student Guide Volume I D17108GC21 Edition 2.1 December 2006 D48183 Authors Chaitanya Koratamaddi Nancy Greenberg Technical Contributors and Reviewers Wayne Abbott
More informationCMPT 354: Database System I. Lecture 3. SQL Basics
CMPT 354: Database System I Lecture 3. SQL Basics 1 Announcements! About Piazza 97 enrolled (as of today) Posts are anonymous to classmates You should have started doing A1 Please come to office hours
More informationCourse Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course:
Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course: 20762C Developing SQL 2016 Databases Module 1: An Introduction to Database Development Introduction to the
More informationFundamental Microsoft Jet SQL for Access 2000
Fundamental Microsoft Jet SQL for Access 2000 (Microsoft Access 2000 Technical... Pagina 1 di 13 MSDN Home > MSDN Library > Office Solutions Development > Access 2000 > Technical Articles Fundamental Microsoft
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 informationOracle Database: SQL and PL/SQL Fundamentals
Oracle University Contact Us: 001-855-844-3881 & 001-800-514-06-9 7 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training
More informationSQL Part 2. Kathleen Durant PhD Northeastern University CS3200 Lesson 6
SQL Part 2 Kathleen Durant PhD Northeastern University CS3200 Lesson 6 1 Outline for today More of the SELECT command Review of the SET operations Aggregator functions GROUP BY functionality JOIN construct
More informationInstitute of Aga. Network Database LECTURER NIYAZ M. SALIH
2017 Institute of Aga Network Database LECTURER NIYAZ M. SALIH Database: A Database is a collection of related data organized in a way that data can be easily accessed, managed and updated. Any piece of
More informationSQL QUERIES. CS121: Relational Databases Fall 2017 Lecture 5
SQL QUERIES CS121: Relational Databases Fall 2017 Lecture 5 SQL Queries 2 SQL queries use the SELECT statement General form is: SELECT A 1, A 2,... FROM r 1, r 2,... WHERE P; r i are the relations (tables)
More informationSql Server Syllabus. Overview
Sql Server Syllabus Overview This SQL Server training teaches developers all the Transact-SQL skills they need to create database objects like Tables, Views, Stored procedures & Functions and triggers
More informationOracle Database 10g: SQL Fundamentals I
Oracle Database 10g: SQL Fundamentals I Volume I Student Guide D17108GC11 Edition 1.1 August 2004 D39766 Author Nancy Greenberg Technical Contributors and Reviewers Wayne Abbott Christian Bauwens Perry
More informationCST272 SQL Server, SQL and the SqlDataSource Page 1
CST272 SQL Server, SQL and the SqlDataSource Page 1 1 2 3 4 5 6 7 8 9 SQL Server, SQL and the SqlDataSource CST272 ASP.NET Microsoft SQL Server A relational database server developed by Microsoft Stores
More informationSQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez
SQL Queries for Mere Mortals Third Edition A Hands-On Guide to Data Manipulation in SQL John L. Viescas Michael J. Hernandez r A TT TAddison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco
More informationAdvanced SQL. Chapter 8 finally!
Advanced SQL Chapter 8 finally! Views (okay so this is Ch 7) We've been saving SQL queries by saving text files Isn't there a better way? Views! basically saved SELECT queries Syntax CREATE VIEW viewname
More informationRetrieving Data Using the SQL SELECT Statement. Copyright 2004, 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 informationMIS2502: Data Analytics SQL Getting Information Out of a Database Part 1: Basic Queries
MIS2502: Data Analytics SQL Getting Information Out of a Database Part 1: Basic Queries JaeHwuen Jung jaejung@temple.edu http://community.mis.temple.edu/jaejung Where we are Now we re here Data entry Transactional
More informationInstructor: Craig Duckett. Lecture 02: Thursday, March 29 th, 2018 SQL Basics and SELECT, FROM, WHERE
Instructor: Craig Duckett Lecture 02: Thursday, March 29 th, 2018 SQL Basics and SELECT, FROM, WHERE 1 Assignment 1 is due LECTURE 5, Tuesday, April 10 th, 2018 in StudentTracker by MIDNIGHT MID-TERM EXAM
More informationDatabase Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 8 Advanced SQL Objectives In this chapter, you will learn: How to use the advanced SQL JOIN operator syntax About the different
More informationOracle Developer Track Course Contents. Mr. Sandeep M Shinde. Oracle Application Techno-Functional Consultant
Oracle Developer Track Course Contents Sandeep M Shinde Oracle Application Techno-Functional Consultant 16 Years MNC Experience in India and USA Trainer Experience Summary:- Sandeep M Shinde is having
More informationOracle Database 11g: SQL Fundamentals I
Oracle Database 11g: SQL Fundamentals I Volume I Student Guide D49996GC11 Edition 1.1 April 2009 D59980 Authors Puja Singh Brian Pottle Technical Contributors and Reviewers Claire Bennett Tom Best Purjanti
More informationWorking with Columns, Characters and Rows. Copyright 2008, Oracle. All rights reserved.
Working with Columns, Characters and Rows What Will I Learn? In this lesson, you will learn to: Apply the concatenation operator to link columns to other columns, arithmetic expressions or constant values
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 informationMariaDB Crash Course. A Addison-Wesley. Ben Forta. Upper Saddle River, NJ Boston. Indianapolis. Singapore Mexico City. Cape Town Sydney.
MariaDB Crash Course Ben Forta A Addison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid Cape Town Sydney Tokyo Singapore Mexico City
More informationIndex. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,
A Access control, 165 granting privileges to users general syntax, GRANT, 170 multiple privileges, 171 PostgreSQL, 166 169 relational databases, 165 REVOKE command, 172 173 SQLite, 166 Aggregate functions
More informationChapter # 7 Introduction to Structured Query Language (SQL) Part II
Chapter # 7 Introduction to Structured Query Language (SQL) Part II Updating Table Rows UPDATE Modify data in a table Basic Syntax: UPDATE tablename SET columnname = expression [, columnname = expression]
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 informationFollow these steps to get started: o Launch MS Access from your start menu. The MS Access startup panel is displayed:
Forms-based Database Queries The topic presents a summary of Chapter 3 in the textbook, which covers using Microsoft Access to manage and query an Access database. The screenshots in this topic are from
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 informationDS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)
DS 1300 - Introduction to SQL Part 1 Single-Table Queries By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Overview 1. SQL introduction & schema definitions 2. Basic single-table
More informationIntroduction to SQL. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011
Introduction to SQL IT 5101 Introduction to Database Systems J.G. Zheng Fall 2011 Overview Using Structured Query Language (SQL) to get the data you want from relational databases Learning basic syntax
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 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 informationLecture 2: Chapter Objectives. Relational Data Structure. Relational Data Model. Introduction to Relational Model & Structured Query Language (SQL)
Lecture 2: Database Resources Management Fall - 1516 Chapter Objectives Basics of Relational Model SQL Basics of SELECT statement Introduction to Relational Model & Structured Query Language (SQL) MIS511-FALL-
More informationCOGS 121 HCI Programming Studio. Week 03 - Tech Lecture
COGS 121 HCI Programming Studio Week 03 - Tech Lecture Housekeeping Assignment #1 extended to Monday night 11:59pm Assignment #2 to be released on Tuesday during lecture Database Management Systems and
More informationPhysical Design of Relational Databases
Physical Design of Relational Databases Chapter 8 Class 06: Physical Design of Relational Databases 1 Physical Database Design After completion of logical database design, the next phase is the design
More informationLecture 2: Chapter Objectives
Lecture 2: Database Resources Management Fall - 1516 Introduction to Relational Model & Structured Query Language (SQL) MIS511-FALL- 1516 1 Chapter Objectives Basics of Relational Model SQL Basics of SELECT
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 information