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

SQL Queries
SQL QueriesSQL Queries
SQL Queries
Nilt1234
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
Sachidananda M H
 
SQL
SQLSQL
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
Syed Hassan Ali
 
Structured query language
Structured query languageStructured query language
Structured query language
Rashid Ansari
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functionsVikas Gupta
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
Sharad Dubey
 
SQL commands
SQL commandsSQL commands
SQL commands
GirdharRatne
 
SQL select clause
SQL select clauseSQL select clause
SQL select clause
arpit bhadoriya
 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
SomeshwarMoholkar
 
Create table
Create tableCreate table
Create table
Nitesh Singh
 
set operators.pptx
set operators.pptxset operators.pptx
set operators.pptx
Anusha sivakumar
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
Ishucs
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
NITISH KUMAR
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
Unit 5 composite datatypes
Unit 5  composite datatypesUnit 5  composite datatypes
Unit 5 composite datatypes
DrkhanchanaR
 

What's hot (20)

SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
SQL
SQLSQL
SQL
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
Structured query language
Structured query languageStructured query language
Structured query language
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
SQL commands
SQL commandsSQL commands
SQL commands
 
SQL select clause
SQL select clauseSQL select clause
SQL select clause
 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
 
Create table
Create tableCreate table
Create table
 
set operators.pptx
set operators.pptxset operators.pptx
set operators.pptx
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Unit 5 composite datatypes
Unit 5  composite datatypesUnit 5  composite datatypes
Unit 5 composite datatypes
 

Similar to SQL: Structured Query Language

sql-commands.pdf
sql-commands.pdfsql-commands.pdf
sql-commands.pdf
Prof. Dr. K. Adisesha
 
Sql commands
Sql commandsSql commands
Sql commands
Prof. Dr. K. Adisesha
 
Sql commands
Sql commandsSql commands
Sql commands
Prof. Dr. K. Adisesha
 
DBMS Part-3.pptx
DBMS Part-3.pptxDBMS Part-3.pptx
DBMS Part-3.pptx
Prof. Dr. K. Adisesha
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
Sheethal Aji Mani
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
mayurisonawane29
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 
Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
shamim hossain
 
chapter-14-sql-commands.pdf
chapter-14-sql-commands.pdfchapter-14-sql-commands.pdf
chapter-14-sql-commands.pdf
study material
 
Oracle notes
Oracle notesOracle notes
Oracle notes
Prashant Dadmode
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
Abrar ali
 
DBMS unit-3.pdf
DBMS unit-3.pdfDBMS unit-3.pdf
DBMS unit-3.pdf
Prof. Dr. K. Adisesha
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
Balqees Al.Mubarak
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
enosislearningcom
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
Dbms
DbmsDbms

Similar to SQL: Structured Query Language (20)

sql-commands.pdf
sql-commands.pdfsql-commands.pdf
sql-commands.pdf
 
Sql commands
Sql commandsSql commands
Sql commands
 
Sql commands
Sql commandsSql commands
Sql commands
 
DBMS Part-3.pptx
DBMS Part-3.pptxDBMS Part-3.pptx
DBMS Part-3.pptx
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
 
chapter-14-sql-commands.pdf
chapter-14-sql-commands.pdfchapter-14-sql-commands.pdf
chapter-14-sql-commands.pdf
 
Oracle notes
Oracle notesOracle notes
Oracle notes
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
DBMS unit-3.pdf
DBMS unit-3.pdfDBMS unit-3.pdf
DBMS unit-3.pdf
 
PT- Oracle session01
PT- Oracle session01 PT- Oracle session01
PT- Oracle session01
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
Dbms
DbmsDbms
Dbms
 

More from Rohit Bisht

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
 

More from Rohit Bisht (11)

Team building
Team buildingTeam building
Team building
 
Business engagement template
Business engagement templateBusiness engagement template
Business engagement template
 
Health care analytics
Health care analyticsHealth care analytics
Health care analytics
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)
 
Geomatics
Geomatics Geomatics
Geomatics
 
Oil and Gas: Upstream
Oil and Gas: UpstreamOil and Gas: Upstream
Oil and Gas: Upstream
 
An overview of cng and png
An overview of cng and pngAn overview of cng and png
An overview of cng and png
 
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
 
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
 
Demmergers hero honda split
Demmergers hero honda splitDemmergers hero honda split
Demmergers hero honda split
 
Maintenance Management
Maintenance ManagementMaintenance Management
Maintenance Management
 

Recently uploaded

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
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
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
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
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
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
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
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
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
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
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
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
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 

Recently uploaded (20)

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
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
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
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...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
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
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
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 ...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
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
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 

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’.