SlideShare a Scribd company logo
1 of 25
Download to read offline
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 (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.pptxssusere4c6aa
 
HOTEL_RESERVATION_PPT.pptx
HOTEL_RESERVATION_PPT.pptxHOTEL_RESERVATION_PPT.pptx
HOTEL_RESERVATION_PPT.pptxssusere4c6aa
 
Payment Gatway.ppt
Payment Gatway.pptPayment Gatway.ppt
Payment Gatway.pptssusere4c6aa
 
STLC & SDLC-ppt-1.pptx
STLC & SDLC-ppt-1.pptxSTLC & SDLC-ppt-1.pptx
STLC & SDLC-ppt-1.pptxssusere4c6aa
 

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

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.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/