SlideShare a Scribd company logo
SQL Fundamentals
© copyright : spiraltrain@gmail.com
Course Schedule
• SQL Intro
• SQL Select Queries
• SQL Data Definition
• SQL Functions
• SQL Data Manipulation
• SQL Joins
• What is SQL?
• History of SQL
• SQL Standard
• SQL Parts
• SQL Environment
• Database Creation
• DDL Create Table
• SQL Data Types
• SQL Language Elements
• DML Insert Into
• SQL Errors
• Select Query
2
www.spiraltrain.nl
What is SQL?
• Abbreviation of Structured Query Language :
• Standard language to access relational database management systems (RDBMS)
• Actually three languages can be distinguished
• Declarative query language with procedural elements :
• Used to create database schemas and to insert, update, delete and query data
• Data Definition Language (DDL) :
• Language that defines database structure (relation schemas)
• This includes creating, altering, and dropping tables and establishing constraints
• Data Manipulation Language (DML) :
• Query language to create, read, update and delete tuples (CRUD operations)
• Data Control Language (DCL) :
• Used to controls a database includes administering privileges and committing data
• SQL language further deals with the following issues :
• Transaction control , integrity constraints, views, embedded SQL and dynamic SQL
3SQL Intro
www.spiraltrain.nl
History of SQL
• SQL started with name SEQUEL in the 1970's :
• Abbreviation of structured english query language
• Developed by Raymond F. Boyce and Donald D. Chamberlin
• Access data stored in IBM's System R relational database
• In 1979 Oracle introduced first commercial version of SQL :
• Oracle V2 (Version2) for VAX computers.
• In 1986 SQL first became an ANSI standard :
• SQL-89 known as SQL 1 was rather incomplete
• SQL-92 is known as first solid standard known as SQL 2
• SQL-99 known as SQL 3 :
— Recursive queries, triggers, object-oriented features
• SQL-2003 :
— Window functions, XML-related features
• SQL-2006 offers XML Query Language (XQuery) support
• SQL-2011 has improved support for temporal databases
SQL Intro 4
www.spiraltrain.nl
SQL Standard
• SQL is standard but is not completely portable among RDBMS :
• This is caused by ambiguities and vendor extensions
• Specific SQL implementation by database vendor is SQL dialect
• Vendors implement parts of the SQL standard, e.g. most implement SQL-92
• Vendors add their vendor-specific extensions
• Most vendors conform to a set of Core SQL features :
• Portability might still be limited due to missing or additional features
• Purpose of SQL-92 and SQL-99 Standards :
• Specify syntax/semantics for data definition and manipulation
• Define data structures
• Enable portability
• Specify minimal (level 1) and complete (level 2) standards
• Allow for later growth/enhancement to standard
5SQL Intro
www.spiraltrain.nl
SQL Parts
6SQL Intro
www.spiraltrain.nl
SQL Environment
• Catalog :
• A set of schemas that constitute the description of a database
• Schema :
• Structure containing descriptions of objects created by a user
• This includes base tables, views, constraints
SQL Intro 7
www.spiraltrain.nl
Database Creation
• Creating of database differs for different relational databases :
• Often done through a GUI interface particular for a database
• According to the SQL standard :
• SQL environment contains one or more catalogues :
• Each catalogue manages various metadata :
• Set of schemas consisting of :
— Relations/tables
— Views
— Assertions
— Indexes
• Users and user groups
• Many database use client-server model :
• You must connect to a remote host on certain port, log in and manage database
• SQLite database does not use this model, databases are files
8SQL Intro
Demo01
Create Database
www.spiraltrain.nl
DDL Create Table
• Relational databases contain data in tables :
• Uniquely identified by their names and are comprised of columns and rows
• Columns contain the column name, data type, and other attributes
• Rows contain the records or data for the columns
• Tables are created through CREATE TABLE statement of SQL DDL :
CREATE TABLE inventory (
StockNumber INTEGER PRIMARY KEY,
Descrip VARCHAR(50),
OnHandQuan INTEGER,
PackQty INTEGER,
PackCost FLOAT
);
• Typically columns are created of certain data type
9SQL Intro
Demo02
DDL Create Table
www.spiraltrain.nl
SQL Data Types
• Columns in a table are of certain data type :
• Often used data types are character strings, numbers and date types
• Character String types :
• CHAR(n) – fixed-length character data, n characters long bytes
• VARCHAR(n) – variable length character data
• LONG – variable-length character data
• Numeric types :
• NUMBER(p,q) – general purpose numeric data type
• INTEGER(p) – signed integer, p digits wide
• INTEGER - signed integer
• FLOAT(p) – floating point in scientific notation with p binary digits precision
• FLOAT – floating point in scientific notation
• Date/time type :
• DATE – fixed-length date/time in dd-mm-yy form
10SQL Intro
www.spiraltrain.nl
SQL Language Elements
• Clauses :
• Constituent components of statements and queries, in some cases optional
• Expressions :
• Can produce either scalar values, or tables consisting of columns and rows of data
• Predicates :
• Specify conditions that can be evaluated to true, false or unknown) values
• Used to limit the effects of statements and queries or to change program flow
• Queries :
• Retrieve the data based on specific criteria
• Statements :
• May have a persistent effect on schemata and data
• May control transactions, program flow, connections, sessions or diagnostics
• SQL statements also include the semicolon (";") statement terminator
• Insignificant whitespace is generally ignored :
• Makes it easier to format SQL code for readability
11SQL Intro
www.spiraltrain.nl
DML Insert Into
• Database table is filled with SQL INSERT INTO statements :
INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost)
VALUES (51002,'AA Dry Cells 4 Pack',173,12,9.00);
INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost)
VALUES (51004,'AA Dry Cells 8 Pack',5,12,16.80);
INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost)
VALUES (43512,'10W-30 Motor Oil, Quart',36,12,18.20);
INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost)
VALUES (51013,'D Dry Cells 8 Pack',19,12,90.20);
INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost)
VALUES (23155,'Shovel Pointed Long Handle',1500,1,9.82);
INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost)
VALUES (51001,'AAA Dry Cells 4 Pack ',92,12,9.00);
INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost)
VALUES (43111,'White Gas Gallon Can',14,4,14.75);
• Values listed in INSERT INTO statement :
• Must be in the same order as appearing in CREATE TABLE
• Character strings are surrounded with quotes, number not
12SQL Intro
Demo03
DML Insert Values
www.spiraltrain.nl
SQL Errors
• SQL State Error Codes are defined by ISO/ANSI SQL Standards :
• 5-character string consisting of 2-characters followed by 3-character subclass value
• "00" indicates success, "01" indicates a warning
• Other class values normally indicate an exception
• Example Error Code :
• SQL0208 - ORDER BY column not in result table
• Typical error is duplicate primary key error :
• Trying to insert row with key already present
13SQL Intro
Demo04
Duplicate Key Error
www.spiraltrain.nl
Select Query
• SELECT clause is used to retrieve data from database tables :
SELECT StockNumber,Descrip,OnHandQuan,PackQty,PackCost from inventory
• SELECT is followed by column names separated by comma’s
• Alternatively wild cards may be used to retrieve all columns :
SELECT * FROM inventory;
• SELECT can be combined with clauses WHERE, ORDER_BY etc.
14SQL Intro
Demo05
Select Query
© copyright : spiraltrain@gmail.com
Summary : SQL Intro
• SQL is a declarative language to access RDBM Systems :
• Used to create database schemas and to query insert, update and delete data
• SQL is standard but is not completely portable among RDBMS’s :
• This is caused by ambiguities and vendor extensions
• SQL consists of three parts :
• Data definition, data manipulation and data control language
• SQL consist of several language elements :
• Clauses, expressions, predicates, queries and statements
• SQL Environments have catalogues with schema’s and users :
• Each schema defines tables, relations, views, assertions and indexes
• SQL Standard defines SQL State Error Codes :
• 5-character string consisting of 2-characters followed by 3-character subclass value
• SQL Standard defines data types :
• Columns in tables are of a certain data type
SQL Intro 15
Exercise 1
SQL Intro

More Related Content

What's hot

Sql tutorial-Structured query language
Sql tutorial-Structured query languageSql tutorial-Structured query language
Sql tutorial-Structured query language
Mayank Bansal
 
Oracle SQL Part 2
Oracle SQL Part 2Oracle SQL Part 2
Oracle SQL Part 2
Gurpreet singh
 
What is SQL Server?
What is SQL Server?What is SQL Server?
What is SQL Server?
CPD INDIA
 
MySQL intro
MySQL introMySQL intro
Netvu test slideshow
Netvu test slideshowNetvu test slideshow
Netvu test slideshow
Ryan Deeds
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
Syed Hassan Ali
 
Oracle sql developer_slides
Oracle sql developer_slidesOracle sql developer_slides
Oracle sql developer_slides
Krishna Murthy
 
Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)
Vidyasagar Mundroy
 
Sqlite
SqliteSqlite
Sqlite
Kumar
 
Dynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data MergeDynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data Merge
Clay Helberg
 
Oracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangaloreOracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangalore
Suvash Chowdary
 
Intro to T-SQL - 1st session
Intro to T-SQL - 1st sessionIntro to T-SQL - 1st session
Intro to T-SQL - 1st session
Medhat Dawoud
 
Oracle SQL Part 3
Oracle SQL Part 3Oracle SQL Part 3
Oracle SQL Part 3
Gurpreet singh
 
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Amanda Lam
 

What's hot (16)

Sql tutorial-Structured query language
Sql tutorial-Structured query languageSql tutorial-Structured query language
Sql tutorial-Structured query language
 
Oracle SQL Part 2
Oracle SQL Part 2Oracle SQL Part 2
Oracle SQL Part 2
 
What is SQL Server?
What is SQL Server?What is SQL Server?
What is SQL Server?
 
MySQL intro
MySQL introMySQL intro
MySQL intro
 
Netvu test slideshow
Netvu test slideshowNetvu test slideshow
Netvu test slideshow
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
Jdbc
JdbcJdbc
Jdbc
 
Oracle sql developer_slides
Oracle sql developer_slidesOracle sql developer_slides
Oracle sql developer_slides
 
Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)
 
treeview
treeviewtreeview
treeview
 
Sqlite
SqliteSqlite
Sqlite
 
Dynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data MergeDynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data Merge
 
Oracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangaloreOracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangalore
 
Intro to T-SQL - 1st session
Intro to T-SQL - 1st sessionIntro to T-SQL - 1st session
Intro to T-SQL - 1st session
 
Oracle SQL Part 3
Oracle SQL Part 3Oracle SQL Part 3
Oracle SQL Part 3
 
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
 

Similar to SQL Intro

Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
Chhom Karath
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
Sachidananda M H
 
Lecture 2 sql {basics date type, constrains , integrity types etc.}
Lecture 2 sql {basics  date type, constrains , integrity types etc.}Lecture 2 sql {basics  date type, constrains , integrity types etc.}
Lecture 2 sql {basics date type, constrains , integrity types etc.}
Shubham Shukla
 
SQL Fundamentals - Lecture 2
SQL Fundamentals - Lecture 2SQL Fundamentals - Lecture 2
SQL Fundamentals - Lecture 2
MuhammadWaheed44
 
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
FayChan8
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
Punjab University
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
Gowarthini
 
BITM3730Week14.pptx
BITM3730Week14.pptxBITM3730Week14.pptx
BITM3730Week14.pptx
MattMarino13
 
SQL Overview-II23-PF20SA8Z.pptx
SQL Overview-II23-PF20SA8Z.pptxSQL Overview-II23-PF20SA8Z.pptx
SQL Overview-II23-PF20SA8Z.pptx
MAYURUGALE6
 
SQL Overview.pptx
SQL Overview.pptxSQL Overview.pptx
SQL Overview.pptx
MAYURUGALE6
 
Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?
Zohar Elkayam
 
unit-ii.pptx
unit-ii.pptxunit-ii.pptx
unit-ii.pptx
NilamHonmane
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
WrushabhShirsat3
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptx
Kulbir4
 
Partially Contained Databases
Partially Contained DatabasesPartially Contained Databases
Partially Contained Databases
Microsoft TechNet - Belgium and Luxembourg
 
Querying_with_T-SQL_-_01.pptx
Querying_with_T-SQL_-_01.pptxQuerying_with_T-SQL_-_01.pptx
Querying_with_T-SQL_-_01.pptx
QuyVo27
 
20180929 jssug 10_a5_sql_mk2
20180929 jssug 10_a5_sql_mk220180929 jssug 10_a5_sql_mk2
20180929 jssug 10_a5_sql_mk2
Kunihisa Abukawa
 

Similar to SQL Intro (20)

Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Lecture 2 sql {basics date type, constrains , integrity types etc.}
Lecture 2 sql {basics  date type, constrains , integrity types etc.}Lecture 2 sql {basics  date type, constrains , integrity types etc.}
Lecture 2 sql {basics date type, constrains , integrity types etc.}
 
Oracle 11g sql plsql training
Oracle 11g sql plsql trainingOracle 11g sql plsql training
Oracle 11g sql plsql training
 
SQL Fundamentals - Lecture 2
SQL Fundamentals - Lecture 2SQL Fundamentals - Lecture 2
SQL Fundamentals - Lecture 2
 
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 
BITM3730Week14.pptx
BITM3730Week14.pptxBITM3730Week14.pptx
BITM3730Week14.pptx
 
SQL Overview-II23-PF20SA8Z.pptx
SQL Overview-II23-PF20SA8Z.pptxSQL Overview-II23-PF20SA8Z.pptx
SQL Overview-II23-PF20SA8Z.pptx
 
SQL Overview.pptx
SQL Overview.pptxSQL Overview.pptx
SQL Overview.pptx
 
Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?
 
unit-ii.pptx
unit-ii.pptxunit-ii.pptx
unit-ii.pptx
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptx
 
3 sql overview
3 sql overview3 sql overview
3 sql overview
 
Partially Contained Databases
Partially Contained DatabasesPartially Contained Databases
Partially Contained Databases
 
Querying_with_T-SQL_-_01.pptx
Querying_with_T-SQL_-_01.pptxQuerying_with_T-SQL_-_01.pptx
Querying_with_T-SQL_-_01.pptx
 
20180929 jssug 10_a5_sql_mk2
20180929 jssug 10_a5_sql_mk220180929 jssug 10_a5_sql_mk2
20180929 jssug 10_a5_sql_mk2
 

More from koppenolski

Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
koppenolski
 
HTML Intro
HTML IntroHTML Intro
HTML Intro
koppenolski
 
Spring Boot
Spring BootSpring Boot
Spring Boot
koppenolski
 
Wicket Intro
Wicket IntroWicket Intro
Wicket Intro
koppenolski
 
R Intro
R IntroR Intro
R Intro
koppenolski
 
Python Intro
Python IntroPython Intro
Python Intro
koppenolski
 
UML Intro
UML IntroUML Intro
UML Intro
koppenolski
 
Intro apache
Intro apacheIntro apache
Intro apache
koppenolski
 

More from koppenolski (8)

Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
 
HTML Intro
HTML IntroHTML Intro
HTML Intro
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Wicket Intro
Wicket IntroWicket Intro
Wicket Intro
 
R Intro
R IntroR Intro
R Intro
 
Python Intro
Python IntroPython Intro
Python Intro
 
UML Intro
UML IntroUML Intro
UML Intro
 
Intro apache
Intro apacheIntro apache
Intro apache
 

Recently uploaded

Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
correoyaya
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
ewymefz
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
vcaxypu
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
James Polillo
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 

Recently uploaded (20)

Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 

SQL Intro

  • 2. © copyright : spiraltrain@gmail.com Course Schedule • SQL Intro • SQL Select Queries • SQL Data Definition • SQL Functions • SQL Data Manipulation • SQL Joins • What is SQL? • History of SQL • SQL Standard • SQL Parts • SQL Environment • Database Creation • DDL Create Table • SQL Data Types • SQL Language Elements • DML Insert Into • SQL Errors • Select Query 2
  • 3. www.spiraltrain.nl What is SQL? • Abbreviation of Structured Query Language : • Standard language to access relational database management systems (RDBMS) • Actually three languages can be distinguished • Declarative query language with procedural elements : • Used to create database schemas and to insert, update, delete and query data • Data Definition Language (DDL) : • Language that defines database structure (relation schemas) • This includes creating, altering, and dropping tables and establishing constraints • Data Manipulation Language (DML) : • Query language to create, read, update and delete tuples (CRUD operations) • Data Control Language (DCL) : • Used to controls a database includes administering privileges and committing data • SQL language further deals with the following issues : • Transaction control , integrity constraints, views, embedded SQL and dynamic SQL 3SQL Intro
  • 4. www.spiraltrain.nl History of SQL • SQL started with name SEQUEL in the 1970's : • Abbreviation of structured english query language • Developed by Raymond F. Boyce and Donald D. Chamberlin • Access data stored in IBM's System R relational database • In 1979 Oracle introduced first commercial version of SQL : • Oracle V2 (Version2) for VAX computers. • In 1986 SQL first became an ANSI standard : • SQL-89 known as SQL 1 was rather incomplete • SQL-92 is known as first solid standard known as SQL 2 • SQL-99 known as SQL 3 : — Recursive queries, triggers, object-oriented features • SQL-2003 : — Window functions, XML-related features • SQL-2006 offers XML Query Language (XQuery) support • SQL-2011 has improved support for temporal databases SQL Intro 4
  • 5. www.spiraltrain.nl SQL Standard • SQL is standard but is not completely portable among RDBMS : • This is caused by ambiguities and vendor extensions • Specific SQL implementation by database vendor is SQL dialect • Vendors implement parts of the SQL standard, e.g. most implement SQL-92 • Vendors add their vendor-specific extensions • Most vendors conform to a set of Core SQL features : • Portability might still be limited due to missing or additional features • Purpose of SQL-92 and SQL-99 Standards : • Specify syntax/semantics for data definition and manipulation • Define data structures • Enable portability • Specify minimal (level 1) and complete (level 2) standards • Allow for later growth/enhancement to standard 5SQL Intro
  • 7. www.spiraltrain.nl SQL Environment • Catalog : • A set of schemas that constitute the description of a database • Schema : • Structure containing descriptions of objects created by a user • This includes base tables, views, constraints SQL Intro 7
  • 8. www.spiraltrain.nl Database Creation • Creating of database differs for different relational databases : • Often done through a GUI interface particular for a database • According to the SQL standard : • SQL environment contains one or more catalogues : • Each catalogue manages various metadata : • Set of schemas consisting of : — Relations/tables — Views — Assertions — Indexes • Users and user groups • Many database use client-server model : • You must connect to a remote host on certain port, log in and manage database • SQLite database does not use this model, databases are files 8SQL Intro Demo01 Create Database
  • 9. www.spiraltrain.nl DDL Create Table • Relational databases contain data in tables : • Uniquely identified by their names and are comprised of columns and rows • Columns contain the column name, data type, and other attributes • Rows contain the records or data for the columns • Tables are created through CREATE TABLE statement of SQL DDL : CREATE TABLE inventory ( StockNumber INTEGER PRIMARY KEY, Descrip VARCHAR(50), OnHandQuan INTEGER, PackQty INTEGER, PackCost FLOAT ); • Typically columns are created of certain data type 9SQL Intro Demo02 DDL Create Table
  • 10. www.spiraltrain.nl SQL Data Types • Columns in a table are of certain data type : • Often used data types are character strings, numbers and date types • Character String types : • CHAR(n) – fixed-length character data, n characters long bytes • VARCHAR(n) – variable length character data • LONG – variable-length character data • Numeric types : • NUMBER(p,q) – general purpose numeric data type • INTEGER(p) – signed integer, p digits wide • INTEGER - signed integer • FLOAT(p) – floating point in scientific notation with p binary digits precision • FLOAT – floating point in scientific notation • Date/time type : • DATE – fixed-length date/time in dd-mm-yy form 10SQL Intro
  • 11. www.spiraltrain.nl SQL Language Elements • Clauses : • Constituent components of statements and queries, in some cases optional • Expressions : • Can produce either scalar values, or tables consisting of columns and rows of data • Predicates : • Specify conditions that can be evaluated to true, false or unknown) values • Used to limit the effects of statements and queries or to change program flow • Queries : • Retrieve the data based on specific criteria • Statements : • May have a persistent effect on schemata and data • May control transactions, program flow, connections, sessions or diagnostics • SQL statements also include the semicolon (";") statement terminator • Insignificant whitespace is generally ignored : • Makes it easier to format SQL code for readability 11SQL Intro
  • 12. www.spiraltrain.nl DML Insert Into • Database table is filled with SQL INSERT INTO statements : INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost) VALUES (51002,'AA Dry Cells 4 Pack',173,12,9.00); INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost) VALUES (51004,'AA Dry Cells 8 Pack',5,12,16.80); INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost) VALUES (43512,'10W-30 Motor Oil, Quart',36,12,18.20); INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost) VALUES (51013,'D Dry Cells 8 Pack',19,12,90.20); INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost) VALUES (23155,'Shovel Pointed Long Handle',1500,1,9.82); INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost) VALUES (51001,'AAA Dry Cells 4 Pack ',92,12,9.00); INSERT INTO inventory(StockNumber,Descrip,OnHandQuan,PackQty,PackCost) VALUES (43111,'White Gas Gallon Can',14,4,14.75); • Values listed in INSERT INTO statement : • Must be in the same order as appearing in CREATE TABLE • Character strings are surrounded with quotes, number not 12SQL Intro Demo03 DML Insert Values
  • 13. www.spiraltrain.nl SQL Errors • SQL State Error Codes are defined by ISO/ANSI SQL Standards : • 5-character string consisting of 2-characters followed by 3-character subclass value • "00" indicates success, "01" indicates a warning • Other class values normally indicate an exception • Example Error Code : • SQL0208 - ORDER BY column not in result table • Typical error is duplicate primary key error : • Trying to insert row with key already present 13SQL Intro Demo04 Duplicate Key Error
  • 14. www.spiraltrain.nl Select Query • SELECT clause is used to retrieve data from database tables : SELECT StockNumber,Descrip,OnHandQuan,PackQty,PackCost from inventory • SELECT is followed by column names separated by comma’s • Alternatively wild cards may be used to retrieve all columns : SELECT * FROM inventory; • SELECT can be combined with clauses WHERE, ORDER_BY etc. 14SQL Intro Demo05 Select Query
  • 15. © copyright : spiraltrain@gmail.com Summary : SQL Intro • SQL is a declarative language to access RDBM Systems : • Used to create database schemas and to query insert, update and delete data • SQL is standard but is not completely portable among RDBMS’s : • This is caused by ambiguities and vendor extensions • SQL consists of three parts : • Data definition, data manipulation and data control language • SQL consist of several language elements : • Clauses, expressions, predicates, queries and statements • SQL Environments have catalogues with schema’s and users : • Each schema defines tables, relations, views, assertions and indexes • SQL Standard defines SQL State Error Codes : • 5-character string consisting of 2-characters followed by 3-character subclass value • SQL Standard defines data types : • Columns in tables are of a certain data type SQL Intro 15 Exercise 1 SQL Intro