SlideShare a Scribd company logo
SQL- STRUCTURED QUERY
LANGUAGE
PART - 1
INTRODUCTION
• It is a computer programming language that is used for storage,
retrieval and manipulation of data that is stored in relational database.
This is a standard computer programming language used for RDMS
(Relational Database Management Systems).
• IBM’s Ted Cod a.k.a Father of Relational databases gave the concept of
relational model for database in 1970. It was 4 years later SQL appeared
in 1974. This was just an idea, which got conceptualized in the form of
Systems/R in 1978 and was released by IBM. The ANSI standards and
first prototype of relational databases was released in 1986, which is
popularly knows as Oracle
ADVANTAGE
• Used for accessing data in RDBMS.
• Used for describing data.
• Definition of data and its manipulation.
• Can be used with other programming language by embedding SQL
modules into other languages code, pre-compilers and libraries.
• Possible to create and drop data base using this programming
language.
• Setting permission on views, table and procedures.
• Can be used for creating views, procedures and functions.
COMMANDS
Commands in SQL are categorized into three category namely
• DDL – Data definition language
• DML – Data Manipulation language
• DCL – Data Control language
DATA DEFINITION LANGUAGE (DDL)
Commands that are classified under DDL category are as follows:
• CREATE – Used for creating an object, table/view.
• ALTER – Used for modifying an existing database object.
• DROP – Object, table an views created using CREATE can be
deleted/removed.
DATA MANIPULATION LANGUAGE (DML)
Commands that are classified under DML are as follows:
• SELECT – Used for retrieving a set of records from one/more than one
tables.
• DELETE – Used for deleting records.
• UPDATE – Used for modifying / updating records.
• INSERT – Used for inserting records.
DATA CONTROL LANGUAGE
Commands that have been classified under DCL are:
GRANT – Users can be granted permission / privileges using this command
REVOKE – Privileges to the user can be taken back using this command.
CONSTRAINTS
Rules are enforced on the columns of the table that contain data specific
for the field for all the record in the table. These rules are referred to as
constraints, which are generally used to ensure that field only gets a
particular type of value. For instance if there is a field called “Age” in the
table, then this field can only take numeric value.
Constraints set up for the table apply to all the data stored in the table.
Some of the common constraints are:
NOT NULL:
This constraints ensure that the field value is never set to NULL
DEFAULT:
Typically used to fill in a default value for any field left blank.
UNIQUE:
If the constraints is set on a column, then all value set for this field will have to be unique
PRIMARY KEY:
When this constraint is set for a column, it indicates that the field is the primary key/the
field value is a unique identifier for every record existent in the table. One Primary key
per table.
FOREIGN KEY:
When this constraint is set for a column, it indicates that the field is the
foreign key/the field value is a unique identifier for every record existent in
another table.
CHECK:
Checks if the values for a field satisfy pre-defined conditions
INDEX:
Can be used as an index (column) which shall be used for faster data
retrieval from the table.
DATA INTEGRITY
It is the measure of the accuracy and consistency of data stored in the
data-base.
ENTITY INTEGRITY:
Refers to the accuracy and consistency of each entity in the database,
which is each record. Therefore, every record must be unique and no
duplicates of any of the records must be there.
DOMAIN INTEGRITY:
Ensures that every field gets valid entries by imposing restrictions on the
type, format and range of values that a field can hold
REFERENTIAL INTEGRITY
Records/rows that are being used by other able in the database cannot be
deleted.
USER-DEFINED INTEGRITY
Any rules that the user wishes to impose on columns and that are not
covered in the other data integrity categories form a part of user defined
integrity category
SYNTAX
SYNTAX
• Every SQL statement should start with a keyword. Some example of this
include SELECT, CREATE, INSERT, DELETE & ALTER.
• Every SQL statement terminates with a semicolon (;)
• SQL is case insensitive
SYNTAX RULES
col Column
t_name Table Name
col_name Column Name
V Value
i_name Index Name
db_name Database Name
cond Conditions
Asterisk (*) means all
SHOW DATABASE:
To see the complete list of commands
SHOW TABLES:
To view a list of tables for the currently selected database
SHOW COLUMNS:
Displays information about the columns in a given table
Eg. SHOW COLUMNS FROM customers;
SELECT:
Is used to select data from a database. The result is stored in a result table, which is called
result – set.
Eg. SELECT first name FROM customers;
MULTIPLE QUERIES:
SELECT first name FROM customer;
SELECT city FROM customers;
SELECTING MULTIPLE QUERIES:
SELECT first name, last name, city FROM customers;
SELECTING ALL COLUMNS:
To retrieve all of the information contained in your table, place an asterisk
(*) sign after the SELECT command.
Eg. SELECT * FROM customers;
DISTINCT:
In situations in which you have multiple duplicates records in a table, it
might make more sense to return only unique records, instead of fetching
duplicates.
Eg. SELECT DISTINCT column_name1, column_name2 FROM table_name.
LIMIT:
By default, all results that satisfy the conditions specified in the SQL
statement are returned. However, sometimes we need to retrieve just a
subset of records. In MySQL, this is accomplished by using the LIMIT
keyword.
SELECT column list FROM table_name LIMIT [Number of records]
Also allows to pick up a set of records from a particular offset.
Eg. We pick up 4 records, starting from the third position
SELECT ID, first name, last name, city FROM customers LIMIT 3,4;
FULLY QUALIFIED NAME:
In SQL, you can provide the table name prior to the column name by
separating them with a dot.
Eg. SELECT city FROM customer;
SELECT customer.city from customer;
ORDER BY:
It is used with SELECT to sort the return data.
SELECT * FROM customers ORDER BY first name;
For multiple columns, the ORDER BY command starts ordering in the same
sequence as the columns It will order by the first column listed, then by the
second and so on.
SELECT * FROM customers ORDER BY last name, age;
WHERE:
Where clause is used to extract only those records that fulfill a specified
condition.
SELECT column_list FROM table_name WHERE condition
COMPARISON OPERATORS
Comparison and Logical Operators are used in the WHERE clause to filter
the data to be used.
OPERATOR DESCRIPTON
= Equal
!= Not Equal
> Greater than
< Less than
>= Greater than/Equal
<= Less than/Equal
BETWEEN Between an exclusive range
Examples of Comparison Operators:
SELECT * FROM customer WHERE id !=5;
SELECT * FROM customer WHERE id BETWEEN 3 AND 7
SELECT id, first name, last name, city FROM customer WHERE city = “New
York”;
FYI incase the text contains apostrophe, use ‘Can’‘t’.
THANK YOU

More Related Content

What's hot (20)

Relational model
Relational modelRelational model
Relational model
Dabbal Singh Mahara
 
Sql commands
Sql commandsSql commands
Sql commands
Prof. Dr. K. Adisesha
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
Anurag
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
Vigneshwaran Sankaran
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTSDATABASE CONSTRAINTS
DATABASE CONSTRAINTS
sunanditaAnand
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
MLG College of Learning, Inc
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
Stewart Rogers
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Beat Signer
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
ammarbrohi
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
Gowarthini
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
VENNILAV6
 
Sql and Sql commands
Sql and Sql commandsSql and Sql commands
Sql and Sql commands
Knowledge Center Computer
 
Relational database
Relational database Relational database
Relational database
Megha Sharma
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
madhav bansal
 
SQL
SQLSQL
SQL
Reimuel Bisnar
 
joins in database
 joins in database joins in database
joins in database
Sultan Arshad
 

Similar to SQL: Structured Query Language (20)

Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
SANTOSH RATH
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
Sachidananda M H
 
SQL
SQLSQL
SQL
Shyam Khant
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
TamiratDejene1
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
mayurisonawane29
 
sql notes Provideby AGN HUB Tech & It Solutions
sql notes Provideby AGN HUB Tech & It Solutionssql notes Provideby AGN HUB Tech & It Solutions
sql notes Provideby AGN HUB Tech & It Solutions
mohanagn2244
 
STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE
SarithaDhanapal
 
Introduction to database and sql fir beginers
Introduction to database and sql fir beginersIntroduction to database and sql fir beginers
Introduction to database and sql fir beginers
reshmi30
 
Sql slid
Sql slidSql slid
Sql slid
pacatarpit
 
SQL Basics and Advanced for analytics.pdf
SQL Basics and Advanced for analytics.pdfSQL Basics and Advanced for analytics.pdf
SQL Basics and Advanced for analytics.pdf
trg4294
 
SQL_BASIC AND ADVANCED.pdf
SQL_BASIC AND ADVANCED.pdfSQL_BASIC AND ADVANCED.pdf
SQL_BASIC AND ADVANCED.pdf
fayoyiwababajide
 
SQL
SQLSQL
SQL
Devyani Chaudhari
 
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
nimsarabuwaa2002
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
Sabana Maharjan
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
SARVESH KUMAR
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
Sheethal Aji Mani
 
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATIONSQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
deeptanshudas100
 
Db1 lecture4
Db1 lecture4Db1 lecture4
Db1 lecture4
Sherif Gad
 
Oracle Notes
Oracle NotesOracle Notes
Oracle Notes
Abhishek Sharma
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
SANTOSH RATH
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
TamiratDejene1
 
sql notes Provideby AGN HUB Tech & It Solutions
sql notes Provideby AGN HUB Tech & It Solutionssql notes Provideby AGN HUB Tech & It Solutions
sql notes Provideby AGN HUB Tech & It Solutions
mohanagn2244
 
STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE
SarithaDhanapal
 
Introduction to database and sql fir beginers
Introduction to database and sql fir beginersIntroduction to database and sql fir beginers
Introduction to database and sql fir beginers
reshmi30
 
SQL Basics and Advanced for analytics.pdf
SQL Basics and Advanced for analytics.pdfSQL Basics and Advanced for analytics.pdf
SQL Basics and Advanced for analytics.pdf
trg4294
 
SQL_BASIC AND ADVANCED.pdf
SQL_BASIC AND ADVANCED.pdfSQL_BASIC AND ADVANCED.pdf
SQL_BASIC AND ADVANCED.pdf
fayoyiwababajide
 
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
4 SQL DML.pptx ASHEN WANNIARACHCHI USESS
nimsarabuwaa2002
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
Sabana Maharjan
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
Sheethal Aji Mani
 
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATIONSQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
deeptanshudas100
 

More from Rohit Bisht (11)

Team building
Team buildingTeam building
Team building
Rohit Bisht
 
Business engagement template
Business engagement templateBusiness engagement template
Business engagement template
Rohit Bisht
 
Health care analytics
Health care analyticsHealth care analytics
Health care analytics
Rohit Bisht
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)
Rohit Bisht
 
Geomatics
Geomatics Geomatics
Geomatics
Rohit Bisht
 
Oil and Gas: Upstream
Oil and Gas: UpstreamOil and Gas: Upstream
Oil and Gas: Upstream
Rohit Bisht
 
An overview of cng and png
An overview of cng and pngAn overview of cng and png
An overview of cng and png
Rohit Bisht
 
Problem of odor pollution and its management solution
Problem of odor pollution and its management solutionProblem of odor pollution and its management solution
Problem of odor pollution and its management solution
Rohit Bisht
 
Effects of the falling price on the global economy
Effects of the falling price on the global economyEffects of the falling price on the global economy
Effects of the falling price on the global economy
Rohit Bisht
 
Demmergers hero honda split
Demmergers hero honda splitDemmergers hero honda split
Demmergers hero honda split
Rohit Bisht
 
Maintenance Management
Maintenance ManagementMaintenance Management
Maintenance Management
Rohit Bisht
 
Business engagement template
Business engagement templateBusiness engagement template
Business engagement template
Rohit Bisht
 
Health care analytics
Health care analyticsHealth care analytics
Health care analytics
Rohit Bisht
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)
Rohit Bisht
 
Oil and Gas: Upstream
Oil and Gas: UpstreamOil and Gas: Upstream
Oil and Gas: Upstream
Rohit Bisht
 
An overview of cng and png
An overview of cng and pngAn overview of cng and png
An overview of cng and png
Rohit Bisht
 
Problem of odor pollution and its management solution
Problem of odor pollution and its management solutionProblem of odor pollution and its management solution
Problem of odor pollution and its management solution
Rohit Bisht
 
Effects of the falling price on the global economy
Effects of the falling price on the global economyEffects of the falling price on the global economy
Effects of the falling price on the global economy
Rohit Bisht
 
Demmergers hero honda split
Demmergers hero honda splitDemmergers hero honda split
Demmergers hero honda split
Rohit Bisht
 
Maintenance Management
Maintenance ManagementMaintenance Management
Maintenance Management
Rohit Bisht
 

Recently uploaded (20)

AI Unboxed - How to Approach AI for Maximum Return
AI Unboxed - How to Approach AI for Maximum ReturnAI Unboxed - How to Approach AI for Maximum Return
AI Unboxed - How to Approach AI for Maximum Return
Merelda
 
Optimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services HelpOptimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services Help
Alice Gray
 
I’d like to resell your CloudStack services, but...
I’d like to resell your CloudStack services, but...I’d like to resell your CloudStack services, but...
I’d like to resell your CloudStack services, but...
ShapeBlue
 
AI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptxAI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptx
Shikha Srivastava
 
Storage Setup for LINSTOR/DRBD/CloudStack
Storage Setup for LINSTOR/DRBD/CloudStackStorage Setup for LINSTOR/DRBD/CloudStack
Storage Setup for LINSTOR/DRBD/CloudStack
ShapeBlue
 
TAFs on WebDriver API - By - Pallavi Sharma.pdf
TAFs on WebDriver API - By - Pallavi Sharma.pdfTAFs on WebDriver API - By - Pallavi Sharma.pdf
TAFs on WebDriver API - By - Pallavi Sharma.pdf
Pallavi Sharma
 
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PCWondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Mudasir
 
PSEP - Salesforce Power of the Platform.pdf
PSEP - Salesforce Power of the Platform.pdfPSEP - Salesforce Power of the Platform.pdf
PSEP - Salesforce Power of the Platform.pdf
ssuser3d62c6
 
Apache CloudStack 101 - Introduction, What’s New and What’s Coming
Apache CloudStack 101 - Introduction, What’s New and What’s ComingApache CloudStack 101 - Introduction, What’s New and What’s Coming
Apache CloudStack 101 - Introduction, What’s New and What’s Coming
ShapeBlue
 
How to Integrate FME with Databricks (and Why You’ll Want To)
How to Integrate FME with Databricks (and Why You’ll Want To)How to Integrate FME with Databricks (and Why You’ll Want To)
How to Integrate FME with Databricks (and Why You’ll Want To)
Safe Software
 
Building Agents with LangGraph & Gemini
Building Agents with LangGraph &  GeminiBuilding Agents with LangGraph &  Gemini
Building Agents with LangGraph & Gemini
HusseinMalikMammadli
 
Proposed Feature: Monitoring and Managing Cloud Usage Costs in Apache CloudStack
Proposed Feature: Monitoring and Managing Cloud Usage Costs in Apache CloudStackProposed Feature: Monitoring and Managing Cloud Usage Costs in Apache CloudStack
Proposed Feature: Monitoring and Managing Cloud Usage Costs in Apache CloudStack
ShapeBlue
 
Automating Call Centers with AI Agents_ Achieving Sub-700ms Latency.docx
Automating Call Centers with AI Agents_ Achieving Sub-700ms Latency.docxAutomating Call Centers with AI Agents_ Achieving Sub-700ms Latency.docx
Automating Call Centers with AI Agents_ Achieving Sub-700ms Latency.docx
Ihor Hamal
 
Eating Our Own Dog Food: How to be taken seriously when it comes to adding va...
Eating Our Own Dog Food: How to be taken seriously when it comes to adding va...Eating Our Own Dog Food: How to be taken seriously when it comes to adding va...
Eating Our Own Dog Food: How to be taken seriously when it comes to adding va...
UXPA Boston
 
CloudStack + KVM: Your Local Cloud Lab
CloudStack + KVM:   Your Local Cloud LabCloudStack + KVM:   Your Local Cloud Lab
CloudStack + KVM: Your Local Cloud Lab
ShapeBlue
 
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc
 
Agentic AI, A Business Overview - May 2025
Agentic AI, A Business Overview - May 2025Agentic AI, A Business Overview - May 2025
Agentic AI, A Business Overview - May 2025
Peter Morgan
 
Stretching CloudStack over multiple datacenters
Stretching CloudStack over multiple datacentersStretching CloudStack over multiple datacenters
Stretching CloudStack over multiple datacenters
ShapeBlue
 
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
HusseinMalikMammadli
 
A simple Introduction to Algorithmic Fairness
A simple Introduction to Algorithmic FairnessA simple Introduction to Algorithmic Fairness
A simple Introduction to Algorithmic Fairness
Paolo Missier
 
AI Unboxed - How to Approach AI for Maximum Return
AI Unboxed - How to Approach AI for Maximum ReturnAI Unboxed - How to Approach AI for Maximum Return
AI Unboxed - How to Approach AI for Maximum Return
Merelda
 
Optimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services HelpOptimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services Help
Alice Gray
 
I’d like to resell your CloudStack services, but...
I’d like to resell your CloudStack services, but...I’d like to resell your CloudStack services, but...
I’d like to resell your CloudStack services, but...
ShapeBlue
 
AI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptxAI needs Hybrid Cloud - TEC conference 2025.pptx
AI needs Hybrid Cloud - TEC conference 2025.pptx
Shikha Srivastava
 
Storage Setup for LINSTOR/DRBD/CloudStack
Storage Setup for LINSTOR/DRBD/CloudStackStorage Setup for LINSTOR/DRBD/CloudStack
Storage Setup for LINSTOR/DRBD/CloudStack
ShapeBlue
 
TAFs on WebDriver API - By - Pallavi Sharma.pdf
TAFs on WebDriver API - By - Pallavi Sharma.pdfTAFs on WebDriver API - By - Pallavi Sharma.pdf
TAFs on WebDriver API - By - Pallavi Sharma.pdf
Pallavi Sharma
 
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PCWondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Mudasir
 
PSEP - Salesforce Power of the Platform.pdf
PSEP - Salesforce Power of the Platform.pdfPSEP - Salesforce Power of the Platform.pdf
PSEP - Salesforce Power of the Platform.pdf
ssuser3d62c6
 
Apache CloudStack 101 - Introduction, What’s New and What’s Coming
Apache CloudStack 101 - Introduction, What’s New and What’s ComingApache CloudStack 101 - Introduction, What’s New and What’s Coming
Apache CloudStack 101 - Introduction, What’s New and What’s Coming
ShapeBlue
 
How to Integrate FME with Databricks (and Why You’ll Want To)
How to Integrate FME with Databricks (and Why You’ll Want To)How to Integrate FME with Databricks (and Why You’ll Want To)
How to Integrate FME with Databricks (and Why You’ll Want To)
Safe Software
 
Building Agents with LangGraph & Gemini
Building Agents with LangGraph &  GeminiBuilding Agents with LangGraph &  Gemini
Building Agents with LangGraph & Gemini
HusseinMalikMammadli
 
Proposed Feature: Monitoring and Managing Cloud Usage Costs in Apache CloudStack
Proposed Feature: Monitoring and Managing Cloud Usage Costs in Apache CloudStackProposed Feature: Monitoring and Managing Cloud Usage Costs in Apache CloudStack
Proposed Feature: Monitoring and Managing Cloud Usage Costs in Apache CloudStack
ShapeBlue
 
Automating Call Centers with AI Agents_ Achieving Sub-700ms Latency.docx
Automating Call Centers with AI Agents_ Achieving Sub-700ms Latency.docxAutomating Call Centers with AI Agents_ Achieving Sub-700ms Latency.docx
Automating Call Centers with AI Agents_ Achieving Sub-700ms Latency.docx
Ihor Hamal
 
Eating Our Own Dog Food: How to be taken seriously when it comes to adding va...
Eating Our Own Dog Food: How to be taken seriously when it comes to adding va...Eating Our Own Dog Food: How to be taken seriously when it comes to adding va...
Eating Our Own Dog Food: How to be taken seriously when it comes to adding va...
UXPA Boston
 
CloudStack + KVM: Your Local Cloud Lab
CloudStack + KVM:   Your Local Cloud LabCloudStack + KVM:   Your Local Cloud Lab
CloudStack + KVM: Your Local Cloud Lab
ShapeBlue
 
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc
 
Agentic AI, A Business Overview - May 2025
Agentic AI, A Business Overview - May 2025Agentic AI, A Business Overview - May 2025
Agentic AI, A Business Overview - May 2025
Peter Morgan
 
Stretching CloudStack over multiple datacenters
Stretching CloudStack over multiple datacentersStretching CloudStack over multiple datacenters
Stretching CloudStack over multiple datacenters
ShapeBlue
 
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
HusseinMalikMammadli
 
A simple Introduction to Algorithmic Fairness
A simple Introduction to Algorithmic FairnessA simple Introduction to Algorithmic Fairness
A simple Introduction to Algorithmic Fairness
Paolo Missier
 

SQL: Structured Query Language

  • 2. INTRODUCTION • It is a computer programming language that is used for storage, retrieval and manipulation of data that is stored in relational database. This is a standard computer programming language used for RDMS (Relational Database Management Systems). • IBM’s Ted Cod a.k.a Father of Relational databases gave the concept of relational model for database in 1970. It was 4 years later SQL appeared in 1974. This was just an idea, which got conceptualized in the form of Systems/R in 1978 and was released by IBM. The ANSI standards and first prototype of relational databases was released in 1986, which is popularly knows as Oracle
  • 3. ADVANTAGE • Used for accessing data in RDBMS. • Used for describing data. • Definition of data and its manipulation. • Can be used with other programming language by embedding SQL modules into other languages code, pre-compilers and libraries. • Possible to create and drop data base using this programming language. • Setting permission on views, table and procedures. • Can be used for creating views, procedures and functions.
  • 4. COMMANDS Commands in SQL are categorized into three category namely • DDL – Data definition language • DML – Data Manipulation language • DCL – Data Control language
  • 5. DATA DEFINITION LANGUAGE (DDL) Commands that are classified under DDL category are as follows: • CREATE – Used for creating an object, table/view. • ALTER – Used for modifying an existing database object. • DROP – Object, table an views created using CREATE can be deleted/removed.
  • 6. DATA MANIPULATION LANGUAGE (DML) Commands that are classified under DML are as follows: • SELECT – Used for retrieving a set of records from one/more than one tables. • DELETE – Used for deleting records. • UPDATE – Used for modifying / updating records. • INSERT – Used for inserting records.
  • 7. DATA CONTROL LANGUAGE Commands that have been classified under DCL are: GRANT – Users can be granted permission / privileges using this command REVOKE – Privileges to the user can be taken back using this command.
  • 8. CONSTRAINTS Rules are enforced on the columns of the table that contain data specific for the field for all the record in the table. These rules are referred to as constraints, which are generally used to ensure that field only gets a particular type of value. For instance if there is a field called “Age” in the table, then this field can only take numeric value. Constraints set up for the table apply to all the data stored in the table.
  • 9. Some of the common constraints are: NOT NULL: This constraints ensure that the field value is never set to NULL DEFAULT: Typically used to fill in a default value for any field left blank. UNIQUE: If the constraints is set on a column, then all value set for this field will have to be unique PRIMARY KEY: When this constraint is set for a column, it indicates that the field is the primary key/the field value is a unique identifier for every record existent in the table. One Primary key per table.
  • 10. FOREIGN KEY: When this constraint is set for a column, it indicates that the field is the foreign key/the field value is a unique identifier for every record existent in another table. CHECK: Checks if the values for a field satisfy pre-defined conditions INDEX: Can be used as an index (column) which shall be used for faster data retrieval from the table.
  • 11. DATA INTEGRITY It is the measure of the accuracy and consistency of data stored in the data-base. ENTITY INTEGRITY: Refers to the accuracy and consistency of each entity in the database, which is each record. Therefore, every record must be unique and no duplicates of any of the records must be there. DOMAIN INTEGRITY: Ensures that every field gets valid entries by imposing restrictions on the type, format and range of values that a field can hold
  • 12. REFERENTIAL INTEGRITY Records/rows that are being used by other able in the database cannot be deleted. USER-DEFINED INTEGRITY Any rules that the user wishes to impose on columns and that are not covered in the other data integrity categories form a part of user defined integrity category
  • 14. SYNTAX • Every SQL statement should start with a keyword. Some example of this include SELECT, CREATE, INSERT, DELETE & ALTER. • Every SQL statement terminates with a semicolon (;) • SQL is case insensitive
  • 15. SYNTAX RULES col Column t_name Table Name col_name Column Name V Value i_name Index Name db_name Database Name cond Conditions Asterisk (*) means all
  • 16. SHOW DATABASE: To see the complete list of commands SHOW TABLES: To view a list of tables for the currently selected database SHOW COLUMNS: Displays information about the columns in a given table Eg. SHOW COLUMNS FROM customers; SELECT: Is used to select data from a database. The result is stored in a result table, which is called result – set. Eg. SELECT first name FROM customers;
  • 17. MULTIPLE QUERIES: SELECT first name FROM customer; SELECT city FROM customers; SELECTING MULTIPLE QUERIES: SELECT first name, last name, city FROM customers; SELECTING ALL COLUMNS: To retrieve all of the information contained in your table, place an asterisk (*) sign after the SELECT command. Eg. SELECT * FROM customers;
  • 18. DISTINCT: In situations in which you have multiple duplicates records in a table, it might make more sense to return only unique records, instead of fetching duplicates. Eg. SELECT DISTINCT column_name1, column_name2 FROM table_name. LIMIT: By default, all results that satisfy the conditions specified in the SQL statement are returned. However, sometimes we need to retrieve just a subset of records. In MySQL, this is accomplished by using the LIMIT keyword. SELECT column list FROM table_name LIMIT [Number of records] Also allows to pick up a set of records from a particular offset. Eg. We pick up 4 records, starting from the third position SELECT ID, first name, last name, city FROM customers LIMIT 3,4;
  • 19. FULLY QUALIFIED NAME: In SQL, you can provide the table name prior to the column name by separating them with a dot. Eg. SELECT city FROM customer; SELECT customer.city from customer; ORDER BY: It is used with SELECT to sort the return data. SELECT * FROM customers ORDER BY first name; For multiple columns, the ORDER BY command starts ordering in the same sequence as the columns It will order by the first column listed, then by the second and so on. SELECT * FROM customers ORDER BY last name, age;
  • 20. WHERE: Where clause is used to extract only those records that fulfill a specified condition. SELECT column_list FROM table_name WHERE condition
  • 21. COMPARISON OPERATORS Comparison and Logical Operators are used in the WHERE clause to filter the data to be used. OPERATOR DESCRIPTON = Equal != Not Equal > Greater than < Less than >= Greater than/Equal <= Less than/Equal BETWEEN Between an exclusive range
  • 22. Examples of Comparison Operators: SELECT * FROM customer WHERE id !=5; SELECT * FROM customer WHERE id BETWEEN 3 AND 7 SELECT id, first name, last name, city FROM customer WHERE city = “New York”; FYI incase the text contains apostrophe, use ‘Can’‘t’.