SlideShare a Scribd company logo
8
Most read
12
Most read
20
Most read
SQL – Structured Query Language By: - Vikash Pandey Roll No: - 43 Bhavan’s Institute of Mgmt. Science 2008-2010
What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases. SQL is an ANSI (American National Standards Institute) standard.
What Can SQL do? SQL can execute queries against a database. SQL can retrieve data from a database. SQL can insert records in a database. SQL can update records in a database. SQL can delete records from a database. SQL can create new databases. SQL can create new tables in a database. SQL can create stored procedures in a database. SQL can create views in a database. SQL can set permissions on tables, procedures, and views.
SQL is a Standard - BUT.... Although SQL is an ANSI (American National Standards Institute) standard, there are many different versions of the SQL language. However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.
SQL DML & DDL SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data Definition Language (DDL). The query and update commands form the DML part of SQL: SELECT  - extracts data from a database UPDATE  - updates data in a database DELETE  - deletes data from a database INSERT INTO  - inserts new data into a database
The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are: CREATE DATABASE  - creates a new database ALTER DATABASE  - modifies a database CREATE TABLE  - creates a new table ALTER TABLE  - modifies a table DROP TABLE  - deletes a table CREATE INDEX  - creates an index (search key) DROP INDEX  - deletes an index
The SQL SELECT Statement The SELECT statement is used to select data from a database. The result is stored in a result table, called the result-set. SQL SELECT Syntax SELECT column_name(s) FROM table_name and SELECT * FROM table_name Note:  SQL is not case sensitive. SELECT is the same as select
Example: - Now we want to select the content of the columns named "LastName" and "FirstName" from the table above. We use the following SELECT statement: SELECT LastName,FirstName FROM Persons The result-set will look like this: P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai
Last Name First Name Das Sirsendu Ray Roshni Banerjee Saurav
SELECT * Example Now we want to select  all  the columns from the "Persons" table. We use the following SELECT statement:  SELECT * FROM Persons  Tip:  The asterisk (*) is a quick way of selecting all columns! The result-set will look like this: P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai
SQL UPDATE Statement The UPDATE statement is used to update existing records in a table. SQL UPDATE Syntax UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value  Note:  Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated!
Example: - We use the following SQL statement: Now we want to update the person “Sinha, Joyeeti" in the "Persons" table. UPDATE Persons SET Address=‘Ernakulam', City=‘Chennai’ WHERE LastName=‘Sinha' AND FirstName='Joyeeti' P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai 4 Sinha Joyeeti
The "Persons" table will now look like this: P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai 4 Sinha Joyeeti Ernakulam Chennai
SQL DELETE Statement The DELETE statement is used to delete rows in a table. SQL DELETE Syntax DELETE FROM table_name WHERE some_column=some_value  Note:  Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted!
Example: - We use the following SQL statement: Now we want to delete the person “Sinha, Joyeeti" in the "Persons" table. DELETE FROM Persons WHERE LastName=‘Sinha' AND FirstName='Joyeeti' P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai 4 Sinha Joyeeti Ernakulam Chennai
It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact: DELETE FROM table_name or DELETE * FROM table_name P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai
SQL INSERT INTO Statement The INSERT INTO statement is used to insert a new row in a table. SQL INSERT INTO Syntax It is possible to write the INSERT INTO statement in two forms.  The first form doesn't specify the column names where the data will be inserted, only their values: INSERT INTO table_name VALUES (value1, value2, value3,...) The second form specifies both the column names and the values to be inserted: INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...)
Example We have the following “Persons” table: - Now we want to insert a new row in the "Persons" table. We use the following SQL statement: INSERT INTO Persons VALUES (4,‘Sinha', 'Joyeeti', ‘Ernakulam', ‘Chennai') P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai
The table would look like: - P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai 4 Sinha Joyeeti Ernakulam Chennai
INSERT Data Only In Specified Columns It is also possible to only add data in specific columns. The following SQL statement will add a new row, but only add data in the "P_Id", "LastName" and the "FirstName" columns: INSERT INTO Persons (P_Id, LastName, FirstName) VALUES (5, ‘Das', ‘Kaustav') P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai 4 Sinha Joyeeti Ernakulam Chennai 5 Das Kaustav

More Related Content

PDF
SQL Overview
PPTX
06.01 sql select distinct
PPTX
8. sql
PPT
Introduction to structured query language (sql)
PPTX
Presentation slides of Sequence Query Language (SQL)
PPTX
Sql commands
PPTX
Structured Query Language
PPTX
Lab2 ddl commands
SQL Overview
06.01 sql select distinct
8. sql
Introduction to structured query language (sql)
Presentation slides of Sequence Query Language (SQL)
Sql commands
Structured Query Language
Lab2 ddl commands

What's hot (20)

PPT
Sql basics and DDL statements
PPT
SQL select statement and functions
PPTX
Sql - Structured Query Language
PPTX
Sql(structured query language)
PPTX
introdution to SQL and SQL functions
PDF
Sql Basics | Edureka
PPT
Introduction to-sql
PPTX
Basic sql Commands
PPT
Working with Databases and MySQL
PPTX
Sql and Sql commands
PPT
Mysql
PPTX
Chapter 1 introduction to sql server
PPTX
Aggregate function
PDF
Sql commands
PDF
Sql tutorial
PPTX
SQL Functions
PPT
SQL Tutorial - Basic Commands
PPTX
SQL commands
Sql basics and DDL statements
SQL select statement and functions
Sql - Structured Query Language
Sql(structured query language)
introdution to SQL and SQL functions
Sql Basics | Edureka
Introduction to-sql
Basic sql Commands
Working with Databases and MySQL
Sql and Sql commands
Mysql
Chapter 1 introduction to sql server
Aggregate function
Sql commands
Sql tutorial
SQL Functions
SQL Tutorial - Basic Commands
SQL commands
Ad

Viewers also liked (20)

PDF
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
PPTX
Sql
PPTX
Wordpress developers new york
PDF
UML perusteet
PDF
T-121.5300 Käyttoliittymasuunnittelu - Mallit
PPTX
Innovative ICT Based Library Services
PPTX
Web based database application design using vb.net and sql server
PDF
[Www.pkbulk.blogspot.com]dbms11
PDF
Sql insert statement
PPTX
6. triggers
PDF
Sql create table statement
PPTX
SAP HANA - Manually to insert_data_table
PDF
Sql wksht-7
ODP
PDF
Part 15 triggerr
PDF
Sql update statement
PDF
Sql delete, truncate, drop statements
PPT
Database presentation
DOCX
PL/SQL Code for Sample Projects
PPT
Oracle Database Trigger
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Sql
Wordpress developers new york
UML perusteet
T-121.5300 Käyttoliittymasuunnittelu - Mallit
Innovative ICT Based Library Services
Web based database application design using vb.net and sql server
[Www.pkbulk.blogspot.com]dbms11
Sql insert statement
6. triggers
Sql create table statement
SAP HANA - Manually to insert_data_table
Sql wksht-7
Part 15 triggerr
Sql update statement
Sql delete, truncate, drop statements
Database presentation
PL/SQL Code for Sample Projects
Oracle Database Trigger
Ad

Similar to Sql – Structured Query Language (20)

PPTX
PPTX
Advanced Database Systems - Presentation 3.pptx
PPT
SQL. It education ppt for reference sql process coding
DOCX
DOCX
SQL Tutorial for BCA-2
DOC
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
PPT
CE 279 - WRITING SQL QUERIES umat edition.ppt
PPT
PPTX
Sql slid
PPT
MS SQL Server 1
DOC
Introduction to sql
PPTX
Structured Query Language (SQL).pptx
PDF
Sql tutorial
DOC
Module 3
PDF
SQL notes 1.pdf
PPTX
PPTX
PDF
Sql overview-1232931296681161-1
PPTX
SQL Query
DOCX
SQL & PLSQL
Advanced Database Systems - Presentation 3.pptx
SQL. It education ppt for reference sql process coding
SQL Tutorial for BCA-2
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
CE 279 - WRITING SQL QUERIES umat edition.ppt
Sql slid
MS SQL Server 1
Introduction to sql
Structured Query Language (SQL).pptx
Sql tutorial
Module 3
SQL notes 1.pdf
Sql overview-1232931296681161-1
SQL Query
SQL & PLSQL

Recently uploaded (20)

PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Basic Mud Logging Guide for educational purpose
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Business Ethics Teaching Materials for college
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
2.FourierTransform-ShortQuestionswithAnswers.pdf
Insiders guide to clinical Medicine.pdf
RMMM.pdf make it easy to upload and study
Basic Mud Logging Guide for educational purpose
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Business Ethics Teaching Materials for college
human mycosis Human fungal infections are called human mycosis..pptx
O7-L3 Supply Chain Operations - ICLT Program
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Abdominal Access Techniques with Prof. Dr. R K Mishra
Module 4: Burden of Disease Tutorial Slides S2 2025
Anesthesia in Laparoscopic Surgery in India
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Final Presentation General Medicine 03-08-2024.pptx
01-Introduction-to-Information-Management.pdf
Complications of Minimal Access Surgery at WLH
Chapter 2 Heredity, Prenatal Development, and Birth.pdf

Sql – Structured Query Language

  • 1. SQL – Structured Query Language By: - Vikash Pandey Roll No: - 43 Bhavan’s Institute of Mgmt. Science 2008-2010
  • 2. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases. SQL is an ANSI (American National Standards Institute) standard.
  • 3. What Can SQL do? SQL can execute queries against a database. SQL can retrieve data from a database. SQL can insert records in a database. SQL can update records in a database. SQL can delete records from a database. SQL can create new databases. SQL can create new tables in a database. SQL can create stored procedures in a database. SQL can create views in a database. SQL can set permissions on tables, procedures, and views.
  • 4. SQL is a Standard - BUT.... Although SQL is an ANSI (American National Standards Institute) standard, there are many different versions of the SQL language. However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.
  • 5. SQL DML & DDL SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data Definition Language (DDL). The query and update commands form the DML part of SQL: SELECT - extracts data from a database UPDATE - updates data in a database DELETE - deletes data from a database INSERT INTO - inserts new data into a database
  • 6. The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are: CREATE DATABASE - creates a new database ALTER DATABASE - modifies a database CREATE TABLE - creates a new table ALTER TABLE - modifies a table DROP TABLE - deletes a table CREATE INDEX - creates an index (search key) DROP INDEX - deletes an index
  • 7. The SQL SELECT Statement The SELECT statement is used to select data from a database. The result is stored in a result table, called the result-set. SQL SELECT Syntax SELECT column_name(s) FROM table_name and SELECT * FROM table_name Note: SQL is not case sensitive. SELECT is the same as select
  • 8. Example: - Now we want to select the content of the columns named "LastName" and "FirstName" from the table above. We use the following SELECT statement: SELECT LastName,FirstName FROM Persons The result-set will look like this: P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai
  • 9. Last Name First Name Das Sirsendu Ray Roshni Banerjee Saurav
  • 10. SELECT * Example Now we want to select all the columns from the "Persons" table. We use the following SELECT statement:  SELECT * FROM Persons Tip: The asterisk (*) is a quick way of selecting all columns! The result-set will look like this: P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai
  • 11. SQL UPDATE Statement The UPDATE statement is used to update existing records in a table. SQL UPDATE Syntax UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated!
  • 12. Example: - We use the following SQL statement: Now we want to update the person “Sinha, Joyeeti" in the "Persons" table. UPDATE Persons SET Address=‘Ernakulam', City=‘Chennai’ WHERE LastName=‘Sinha' AND FirstName='Joyeeti' P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai 4 Sinha Joyeeti
  • 13. The "Persons" table will now look like this: P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai 4 Sinha Joyeeti Ernakulam Chennai
  • 14. SQL DELETE Statement The DELETE statement is used to delete rows in a table. SQL DELETE Syntax DELETE FROM table_name WHERE some_column=some_value Note: Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted!
  • 15. Example: - We use the following SQL statement: Now we want to delete the person “Sinha, Joyeeti" in the "Persons" table. DELETE FROM Persons WHERE LastName=‘Sinha' AND FirstName='Joyeeti' P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai 4 Sinha Joyeeti Ernakulam Chennai
  • 16. It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact: DELETE FROM table_name or DELETE * FROM table_name P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai
  • 17. SQL INSERT INTO Statement The INSERT INTO statement is used to insert a new row in a table. SQL INSERT INTO Syntax It is possible to write the INSERT INTO statement in two forms. The first form doesn't specify the column names where the data will be inserted, only their values: INSERT INTO table_name VALUES (value1, value2, value3,...) The second form specifies both the column names and the values to be inserted: INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...)
  • 18. Example We have the following “Persons” table: - Now we want to insert a new row in the "Persons" table. We use the following SQL statement: INSERT INTO Persons VALUES (4,‘Sinha', 'Joyeeti', ‘Ernakulam', ‘Chennai') P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai
  • 19. The table would look like: - P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai 4 Sinha Joyeeti Ernakulam Chennai
  • 20. INSERT Data Only In Specified Columns It is also possible to only add data in specific columns. The following SQL statement will add a new row, but only add data in the "P_Id", "LastName" and the "FirstName" columns: INSERT INTO Persons (P_Id, LastName, FirstName) VALUES (5, ‘Das', ‘Kaustav') P-Id Last Name First Name Address City 1 Das Sirsendu Barrackpur Kolkata 2 Ray Roshni Dwarka Delhi 3 Banerjee Saurav Andheri Mumbai 4 Sinha Joyeeti Ernakulam Chennai 5 Das Kaustav

Editor's Notes

  • #5: Note: Most of the SQL database programs also have their own proprietary extensions in addition to the SQL standard!