NTAUG Introduction in to use of SQL Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,

Slides:



Advertisements
Similar presentations
NTAUG Introduction in to use of SQL - Part 2 Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,
Advertisements

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
SQL -I Reading: C&B, Chaps 6, 7, 8 & 9. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The basic concepts and principles.
Query Methods (SQL). What is SQL A programming language for databases. SQL (structured Query Language) It allows you add, edit, delete and run queries.
Basic SQL Introduction Presented by: Madhuri Bhogadi.
Structure Query Language (SQL) COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, VEHARI.
Chapter 8 Special-Purpose Languages. SQL SQL stands for "Structured Query Language". Allows the user to pose complex questions of a database. It also.
This course has taken from This unique introductory SQL tutorial not only provides easy-to-understand SQL instructions, but it allows.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Structured Query Language Part I Chapter Three CIS 218.
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
Introduction to SQL Session 1 Retrieving Data From a Single Table.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Concepts of Database Management Sixth Edition
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
ASP.NET Programming with C# and SQL Server First Edition
Learningcomputer.com SQL Server 2008 – Introduction to Transact SQL.
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Introduction to SQL Steve Perry
Web Services Week 8 Aims: –Using web services as front ends to databases Objectives: –Review of relational databases –Connecting to and querying databases.
1 Structured Query Language (SQL) CIS*2450 Advanced Programming Concepts.
University of Sunderland COM 220Lecture Two Slide 1 Database Theory.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
Copyright © Curt Hill SQL The Intergalactic Standard Database Query Language.
“INTRODUCTION TO DATABASE AND SQL”. Outlines 2  Introduction To Database  Database Concepts  Database Properties  What is Database Management System.
Tutorial 6 SQL Muhammad Sulayman
Chapter 10: The Data Tier We discuss back-end data storage for Web applications, relational data, and using the MySQL database server for back-end storage.
BY SATHISH SQL Basic. Introduction The language Structured English Query Language (SEQUEL) was developed by IBM Corporation, Inc., to use Codd's model.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
Introduction to Oracle In June 1970,Dr E.F.Codd’s a published A paper entitled A relational model of Data for large shared data banks. This relational.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
Chapter 13 Views Oracle 10g: SQL. Oracle 10g: SQL2 Objectives Create a view, using CREATE VIEW command or the CREATE OR REPLACE VIEW command Employ the.
Assoc. Prof. Dr. Ahmet Turan ÖZCERİT.  Basic SQL syntax  Data retrieve  Data query  Data conditions  Arithmetic operations on data  Data transactions.
NSF DUE ; Wen M. Andrews J. Sargeant Reynolds Community College Richmond, Virginia.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
SQL. Originally developed by IBM Standardized in 80’s by ANSI and ISO Language to access relational database and English-like non-procedural Predominant.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
SQL Definition: Structured Query Language An industry-standard language for creating, updating and, querying relational database management systems.relational.
Create Views Using a Graphical Designer Database Administration Fundamentals LESSON 2.3b.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
© Virtual University of Pakistan Database Management System Lecture - 24.
SQL Introduction SQL stands for “Structured Query Language” and can be pronounced as “SQL” or “sequel – (Structured English.
3 A Guide to MySQL.
Session 1 Retrieving Data From a Single Table
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Chapter 10 SQL DDL.
“Introduction To Database and SQL”
MySQL Subquery Source: Dev.MySql.com
REV 00 Chapter 4 SQL and QBE DDC 2483 – Database Systems.
“Introduction To Database and SQL”
Introduction To Structured Query Language (SQL)
Structured Query Language
Lesson 3 Chapter 10.
Charles Severance Single Table SQL.
Presentation transcript:

NTAUG Introduction in to use of SQL Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,

SQL Some History Some History

SQL Grew out of IBMs System/R project in 1974 Grew out of IBMs System/R project in 1974

SQL Some History Some History Grew out of IBMs System/R project in 1974 Grew out of IBMs System/R project in 1974 Originally Structured English Query Language which is why we pronounce it sequel. Originally Structured English Query Language which is why we pronounce it sequel.

SQL Some History Some History Grew out of IBMs System/R project in 1974 Grew out of IBMs System/R project in 1974 Originally Structured English Query Language which is why we pronounce it sequel. Originally Structured English Query Language which is why we pronounce it sequel. Oracle, in 1979 had SQL as its query language Oracle, in 1979 had SQL as its query language

SQL Some History Some History Grew out of IBMs System/R project in 1974 Grew out of IBMs System/R project in 1974 Originally Structured English Query Language which is why we pronounce it sequel. Originally Structured English Query Language which is why we pronounce it sequel. Oracle, in 1979 had SQL as its query language Oracle, in 1979 had SQL as its query language After DB2 arrived and SQL became accepted, ANSI/ISO standards developed After DB2 arrived and SQL became accepted, ANSI/ISO standards developed

SQL Used in

Oracle Oracle SyBase SyBase DB2 DB2 SQLServer SQLServer MySQL MySQL Others Others

SQL Overview SQL is the standard database language for most commercial relational databases. It's wide acceptance stems from its ability to manage all of the necessary database manipulations while remaining relatively easy to learn. SQL is the standard database language for most commercial relational databases. It's wide acceptance stems from its ability to manage all of the necessary database manipulations while remaining relatively easy to learn.

SQL Overview SQL is the standard database language for most commercial relational databases. It's wide acceptance stems from its ability to manage all of the necessary database manipulations while remaining relatively easy to learn. SQL is the standard database language for most commercial relational databases. It's wide acceptance stems from its ability to manage all of the necessary database manipulations while remaining relatively easy to learn. English-like command structure makes it readable, while providing for the most complex of database functionality. English-like command structure makes it readable, while providing for the most complex of database functionality.

SQL Overview SQL is the standard database language for most commercial relational databases. It's wide acceptance stems from its ability to manage all of the necessary database manipulations while remaining relatively easy to learn. SQL is the standard database language for most commercial relational databases. It's wide acceptance stems from its ability to manage all of the necessary database manipulations while remaining relatively easy to learn. English-like command structure makes it readable, while providing for the most complex of database functionality. English-like command structure makes it readable, while providing for the most complex of database functionality. 40+ SQL statements follow the same basic structure, structural consistency keeps it easy to read and learn 40+ SQL statements follow the same basic structure, structural consistency keeps it easy to read and learn

SQL Structure All statements start with All statements start with

SQL Structure All statements start with All statements start with A verb, A verb,

SQL Structure All statements start with All statements start with A verb, A verb, select select

SQL Structure All statements start with All statements start with A verb, A verb, Select Select Insert Insert Delete Delete Update Update

SQL Structure All statements start with All statements start with A verb, A verb, Select Select Insert Insert Delete Delete Update Update A list of tables and/or fields follow the verb A list of tables and/or fields follow the verb Followed by a clause or clauses Followed by a clause or clauses

SQL Structure Consider the following: Consider the following: SELECT job_name,machine FROM job WHERE machine=somename SELECT job_name,machine FROM job WHERE machine=somename

SQL Structure The verb defines this as a SELECT statement, which retrieves rows from a table. We are selecting two columns, job_name and machine from the table, job. The verb defines this as a SELECT statement, which retrieves rows from a table. We are selecting two columns, job_name and machine from the table, job. Two clauses follow the SELECT statement with the keywords FROM and WHERE. The FROM clause selects the two columns from a table named job", while the WHERE clause includes the expression that we only want data from rows where the machine is somename. This query's result would be a list of jobs for the machine somename. Two clauses follow the SELECT statement with the keywords FROM and WHERE. The FROM clause selects the two columns from a table named job", while the WHERE clause includes the expression that we only want data from rows where the machine is somename. This query's result would be a list of jobs for the machine somename.

SQL Structure Another example: Another example: SELECT job_name FROM job WHERE machine=somename AND owner=root SELECT job_name FROM job WHERE machine=somename AND owner=root

SQL Structure We have here created a query that no only selects the jobs that are run on a particular machine (somename) but refined it to select only those that are run on that machine AND owned by the user root We have here created a query that no only selects the jobs that are run on a particular machine (somename) but refined it to select only those that are run on that machine AND owned by the user root

SQL Structure A further example: A further example: SELECT job_name FROM job WHERE machine=somename AND owner=fred AND command='/sybasedv/dbaroot/bin/do_dbcc.k sh -Dmaster -SAUTOSYS_SQL_DEV1' SELECT job_name FROM job WHERE machine=somename AND owner=fred AND command='/sybasedv/dbaroot/bin/do_dbcc.k sh -Dmaster -SAUTOSYS_SQL_DEV1'

SQL Structure This highlights two important points This highlights two important points

SQL Structure This highlights two important points This highlights two important points The any number of clauses can be appended to refine the statement The any number of clauses can be appended to refine the statement

SQL Structure This highlights two important points This highlights two important points The any number of clauses can be appended to refine the statement and The any number of clauses can be appended to refine the statement and The text can be included as fully as you wish, so long as it is enclosed in quotes The text can be included as fully as you wish, so long as it is enclosed in quotes

SQL Structure This highlights two important points This highlights two important points The any number of clauses can be appended to refine the statement and The any number of clauses can be appended to refine the statement and The text can be included as fully as you wish, so long as it is enclosed in quits The text can be included as fully as you wish, so long as it is enclosed in quits Please note – ignore MSs stupid quote marks, they are just single quotes Please note – ignore MSs stupid quote marks, they are just single quotes

SQL clauses The extend and power of SQL lays in the clauses you can construct. The extend and power of SQL lays in the clauses you can construct.

SQL clauses The extend and power of SQL lays in the clauses you can construct. The extend and power of SQL lays in the clauses you can construct. Take the earlier statement: Take the earlier statement: SELECT job_name FROM job WHERE machine=somename AND owner=fred AND command='/sybasedv/dbaroot/bin/do_dbcc.ksh - Dmaster -SAUTOSYS_SQL_DEV1' SELECT job_name FROM job WHERE machine=somename AND owner=fred AND command='/sybasedv/dbaroot/bin/do_dbcc.ksh - Dmaster -SAUTOSYS_SQL_DEV1'

SQL LIKE clause The extend and power of SQL lays in the clauses you can construct. The extend and power of SQL lays in the clauses you can construct. To make it find jobs that have similar commands we could have a state: To make it find jobs that have similar commands we could have a state: SELECT job_name FROM job WHERE machine=somename AND owner=fred AND command LIKE %dbcc% SELECT job_name FROM job WHERE machine=somename AND owner=fred AND command LIKE %dbcc% Here we are finding anything that has the string dbcc in it from the column command Here we are finding anything that has the string dbcc in it from the column command % is used as a wild card. % is used as a wild card.

SQL DISTINCT clause The extend and power of SQL lays in the clauses you can construct. The extend and power of SQL lays in the clauses you can construct. To find all the machines that have jobs defined, but only list each unique machines name: To find all the machines that have jobs defined, but only list each unique machines name: SELECT DISTINCT machine FROM job SELECT DISTINCT machine FROM job

SQL DISTINCT clause The extend and power of SQL lays in the clauses you can construct. The extend and power of SQL lays in the clauses you can construct. To find all the machines that have jobs defined, but only list each unique machines name: To find all the machines that have jobs defined, but only list each unique machines name: SELECT DISTINCT machine FROM job SELECT DISTINCT machine FROM job And then order it in a simple alphabetical order And then order it in a simple alphabetical order SELECT DISTINCT machine FROM job ORDER BY machine SELECT DISTINCT machine FROM job ORDER BY machine

SQL WHERE clause We touched earlier on the where clause We touched earlier on the where clause

SQL WHERE clause We touched earlier on the where clause We touched earlier on the where clause SELECT job_name FROM job WHERE machine=somename SELECT job_name FROM job WHERE machine=somename And made the use of the simplest form, equals =

SQL WHERE clause We touched earlier on the where clause We touched earlier on the where clause SELECT job_name FROM job WHERE machine=somename SELECT job_name FROM job WHERE machine=somename And made the use of the simplest form and equals = There are other operators:

SQL WHERE clause We touched earlier on the where clause We touched earlier on the where clause SELECT job_name FROM job WHERE machine=somename SELECT job_name FROM job WHERE machine=somename And made the use of the simplest form and equals = There are other operators: =Equal <>Not equal >Greater than <Less than >=Greater than or equal <=Less than or equal BETWEEN Between an inclusive range LIKESearch for a pattern

SQL WHERE clause To extract information where you have a list of items: To extract information where you have a list of items: SELECT job_name FROM job WHERE machine IN (machine1,machinezxt,machine1b) SELECT job_name FROM job WHERE machine IN (machine1,machinezxt,machine1b)

SQL Select within Select SELECT job_name FROM job WHERE machine IN (SELECT hostname FROM keymaster) SELECT job_name FROM job WHERE machine IN (SELECT hostname FROM keymaster)

SQL Information from multiple tables Examine the following statement: Examine the following statement: SELECT keymaster.hostid, job.job_name FROM keymaster, job WHERE job.machine=keymaster.hostname SELECT keymaster.hostid, job.job_name FROM keymaster, job WHERE job.machine=keymaster.hostname

SQL Introduction As stated earlier, this was introduction to SQL and hopefully has provided a taste of the things that can be done to extract information directly from the AutoSys database. As stated earlier, this was introduction to SQL and hopefully has provided a taste of the things that can be done to extract information directly from the AutoSys database.

SQL Introduction As stated earlier, this was introduction to SQL and hopefully has provided a taste of the things that can be done to extract information directly from the AutoSys database. As stated earlier, this was introduction to SQL and hopefully has provided a taste of the things that can be done to extract information directly from the AutoSys database