SlideShare a Scribd company logo
Introduction to
SQL
UNIVERSITY OF TEHRAN
NOVEMBER, 2016
What is SQL?
 Structured Query Language
 SQL is Structured Query Language, which is a
computer language for storing, manipulating and
retrieving data stored in relational database.
 SQL is the standard language for Relation Database
System. All relational database management systems
like “MySQL, MS Access, Oracle, Sybase, Informix,
postgres and SQL Server” use SQL as standard
database language.
SQL Commands
 DDL - Data Definition Language
 DML - Data Manipulation Language
 DCL - Data Control Language
 DQL - Data Query Language
SQL Commands
SQL Commands
SQL RDBMS Concepts
 TABLE
 RECORD
 COLUMN
 CELL
 NULL?
SQL RDBMS Concepts
 SQL Constraints: (applied on columns)
 NOT NULL Constraint
 UNIQUE Constraint
 PRIMARY Key
 FOREIGN Key
 CHECK Constraint
 Data Integrity:
 Entity Integrity: There are no duplicate rows in a table
 Domain Integrity: Enforces valid entries for a given column by
restricting the type
 Referential Integrity: Rows cannot be deleted which are used by
other records
 User-Defined Integrity: Enforces some specific business rules
SQL RDBMS Concepts
 Data Types:
 Character datatypes:
 CHAR
 NCHAR
 NVARCHAR2
 VARCHAR2
 Numeric datatypes:
 NUMBER
 BINARY_FLOAT
 BINARY_DOUBLE
 Date time datatype:
 DATE
DCL: CREATE USER
 1) Define User with Username/Password
 2) Grants Sufficient Privileges.
 Using SQL Developer (UI, Command)
 Using SQL *PLUS (Command)
SQL : DDL
 Create Table:
 COLUMNS
 CONSTRAINTS
SQL: DDL
 DROP TABLE:
 ALTER TABLE
 OTHER DDL COMMANDS!!!!
SQL: DML: INSERT
 INSERT INTO:
 NUMBER, CHAR/VARCHAR2, DATE?
SQL: DML: INSERT
 INSERT INTO:
 SPECIFIC COLUMNS
SQL: DML: INSERT
 INSERT INTO:
 FOREIGN KEY
 ALL DML COMMANDS NEED COMMIT
SQL: DML: UPDATE
 UPDATE
 WHERE CLAUSE
SQL: DML: DELETE
 DELETE (DELETE VS DROP????)
HR-Schema
SQL: DQL: SELECT
 SELECT
 *
 SPECIFIC COLUMNS
SQL: DQL: SELECT
 DISTINCT CLUASE
SQL: DQL: SELECT
 WHERE CLUASE
SQL: DQL: SELECT
 IN CLUASE
 NOT IN
 NULL IN WHERE?
 IS NULL
 IS NOT NULL
SQL: DQL: SELECT
 ORDER BY
SQL: DQL: SELECT
 GROUP BY
 AGGREGATE FUCTION
 MAX,MIN
 AVG
 COUNT
 SUM
 …
 HAVING CLAUSE
SQL: DQL: SELECT
 SELECT FROM MULTIPLE TABLES
 CARTESIAN MULTIPICATION
 JOIN
About Me
 Ehsan Hamzei
 Graduate Student of Geospatial Information System
 University of Tehran
 Git-Hub: https://github.com/ehsan-hamzei/
 Source-Codes: https://github.com/ehsan-
hamzei/Oracle-SQL/

More Related Content

Similar to introductiontosql-161216154706.pdf

Introduction to SQL.pptx
Introduction to SQL.pptxIntroduction to SQL.pptx
Introduction to SQL.pptx
shubhidas
 
SQL Introduction.pptx
SQL Introduction.pptxSQL Introduction.pptx
SQL Introduction.pptx
RUBAB79
 
Sql database development part 1
Sql database development part 1Sql database development part 1
Sql database development part 1
Sqlperfomance
 
Sq lite module5
Sq lite module5Sq lite module5
Sq lite module5
Highervista
 
MySQL intro
MySQL introMySQL intro
MySQL intro
MySQL introMySQL intro
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
Danish Mehraj
 
Database Fundamental
Database FundamentalDatabase Fundamental
Database Fundamental
Gong Haibing
 
DBMS Part-3.pptx
DBMS Part-3.pptxDBMS Part-3.pptx
DBMS Part-3.pptx
Prof. Dr. K. Adisesha
 
Lab
LabLab
Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
shamim hossain
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
Nitesh Singh
 
Chapter 2: Ms SQL Server
Chapter 2: Ms SQL ServerChapter 2: Ms SQL Server
Chapter 2: Ms SQL ServerNgeam Soly
 
Assignment#01
Assignment#01Assignment#01
Assignment#01
Sunita Milind Dol
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
Zespół Szkół nr 26
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
MLG College of Learning, Inc
 
What is SQL Server?
What is SQL Server?What is SQL Server?
What is SQL Server?
CPD INDIA
 

Similar to introductiontosql-161216154706.pdf (20)

Introduction to SQL.pptx
Introduction to SQL.pptxIntroduction to SQL.pptx
Introduction to SQL.pptx
 
SQL Introduction.pptx
SQL Introduction.pptxSQL Introduction.pptx
SQL Introduction.pptx
 
Sql database development part 1
Sql database development part 1Sql database development part 1
Sql database development part 1
 
lovely
lovelylovely
lovely
 
Sq lite module5
Sq lite module5Sq lite module5
Sq lite module5
 
MySQL intro
MySQL introMySQL intro
MySQL intro
 
MySQL intro
MySQL introMySQL intro
MySQL intro
 
SQL overview and software
SQL overview and softwareSQL overview and software
SQL overview and software
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 
Database Fundamental
Database FundamentalDatabase Fundamental
Database Fundamental
 
DBMS Part-3.pptx
DBMS Part-3.pptxDBMS Part-3.pptx
DBMS Part-3.pptx
 
Lab
LabLab
Lab
 
Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
 
Chapter 2: Ms SQL Server
Chapter 2: Ms SQL ServerChapter 2: Ms SQL Server
Chapter 2: Ms SQL Server
 
Assignment#01
Assignment#01Assignment#01
Assignment#01
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
What is SQL Server?
What is SQL Server?What is SQL Server?
What is SQL Server?
 

More from ssusere4c6aa

Selenium PPT 2.pptx
Selenium PPT 2.pptxSelenium PPT 2.pptx
Selenium PPT 2.pptx
ssusere4c6aa
 
HOTEL_RESERVATION_PPT.pptx
HOTEL_RESERVATION_PPT.pptxHOTEL_RESERVATION_PPT.pptx
HOTEL_RESERVATION_PPT.pptx
ssusere4c6aa
 
lecture10.ppt
lecture10.pptlecture10.ppt
lecture10.ppt
ssusere4c6aa
 
Payment Gatway.ppt
Payment Gatway.pptPayment Gatway.ppt
Payment Gatway.ppt
ssusere4c6aa
 
Agile.docx
Agile.docxAgile.docx
Agile.docx
ssusere4c6aa
 
STLC & SDLC-ppt-1.pptx
STLC & SDLC-ppt-1.pptxSTLC & SDLC-ppt-1.pptx
STLC & SDLC-ppt-1.pptx
ssusere4c6aa
 

More from ssusere4c6aa (6)

Selenium PPT 2.pptx
Selenium PPT 2.pptxSelenium PPT 2.pptx
Selenium PPT 2.pptx
 
HOTEL_RESERVATION_PPT.pptx
HOTEL_RESERVATION_PPT.pptxHOTEL_RESERVATION_PPT.pptx
HOTEL_RESERVATION_PPT.pptx
 
lecture10.ppt
lecture10.pptlecture10.ppt
lecture10.ppt
 
Payment Gatway.ppt
Payment Gatway.pptPayment Gatway.ppt
Payment Gatway.ppt
 
Agile.docx
Agile.docxAgile.docx
Agile.docx
 
STLC & SDLC-ppt-1.pptx
STLC & SDLC-ppt-1.pptxSTLC & SDLC-ppt-1.pptx
STLC & SDLC-ppt-1.pptx
 

Recently uploaded

AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 

Recently uploaded (20)

AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 

introductiontosql-161216154706.pdf

  • 1. Introduction to SQL UNIVERSITY OF TEHRAN NOVEMBER, 2016
  • 2. What is SQL?  Structured Query Language  SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving data stored in relational database.  SQL is the standard language for Relation Database System. All relational database management systems like “MySQL, MS Access, Oracle, Sybase, Informix, postgres and SQL Server” use SQL as standard database language.
  • 3. SQL Commands  DDL - Data Definition Language  DML - Data Manipulation Language  DCL - Data Control Language  DQL - Data Query Language
  • 6. SQL RDBMS Concepts  TABLE  RECORD  COLUMN  CELL  NULL?
  • 7. SQL RDBMS Concepts  SQL Constraints: (applied on columns)  NOT NULL Constraint  UNIQUE Constraint  PRIMARY Key  FOREIGN Key  CHECK Constraint  Data Integrity:  Entity Integrity: There are no duplicate rows in a table  Domain Integrity: Enforces valid entries for a given column by restricting the type  Referential Integrity: Rows cannot be deleted which are used by other records  User-Defined Integrity: Enforces some specific business rules
  • 8. SQL RDBMS Concepts  Data Types:  Character datatypes:  CHAR  NCHAR  NVARCHAR2  VARCHAR2  Numeric datatypes:  NUMBER  BINARY_FLOAT  BINARY_DOUBLE  Date time datatype:  DATE
  • 9. DCL: CREATE USER  1) Define User with Username/Password  2) Grants Sufficient Privileges.  Using SQL Developer (UI, Command)  Using SQL *PLUS (Command)
  • 10. SQL : DDL  Create Table:  COLUMNS  CONSTRAINTS
  • 11. SQL: DDL  DROP TABLE:  ALTER TABLE  OTHER DDL COMMANDS!!!!
  • 12. SQL: DML: INSERT  INSERT INTO:  NUMBER, CHAR/VARCHAR2, DATE?
  • 13. SQL: DML: INSERT  INSERT INTO:  SPECIFIC COLUMNS
  • 14. SQL: DML: INSERT  INSERT INTO:  FOREIGN KEY  ALL DML COMMANDS NEED COMMIT
  • 15. SQL: DML: UPDATE  UPDATE  WHERE CLAUSE
  • 16. SQL: DML: DELETE  DELETE (DELETE VS DROP????)
  • 18. SQL: DQL: SELECT  SELECT  *  SPECIFIC COLUMNS
  • 19. SQL: DQL: SELECT  DISTINCT CLUASE
  • 20. SQL: DQL: SELECT  WHERE CLUASE
  • 21. SQL: DQL: SELECT  IN CLUASE  NOT IN  NULL IN WHERE?  IS NULL  IS NOT NULL
  • 23. SQL: DQL: SELECT  GROUP BY  AGGREGATE FUCTION  MAX,MIN  AVG  COUNT  SUM  …  HAVING CLAUSE
  • 24. SQL: DQL: SELECT  SELECT FROM MULTIPLE TABLES  CARTESIAN MULTIPICATION  JOIN
  • 25. About Me  Ehsan Hamzei  Graduate Student of Geospatial Information System  University of Tehran  Git-Hub: https://github.com/ehsan-hamzei/  Source-Codes: https://github.com/ehsan- hamzei/Oracle-SQL/