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

PPT
Introduction to structured query language (sql)
PPTX
Structured query language(sql)ppt
PDF
Sql tutorial
PPT
Introduction to sql
PPTX
Sql commands
PPTX
Sql Functions And Procedures
PPT
Introduction to-sql
PPTX
SQL Server Learning Drive
Introduction to structured query language (sql)
Structured query language(sql)ppt
Sql tutorial
Introduction to sql
Sql commands
Sql Functions And Procedures
Introduction to-sql
SQL Server Learning Drive

What's hot (20)

PPTX
PPTX
SQL - DML and DDL Commands
PPTX
Sql and Sql commands
PPTX
Bootcamp sql fundamental
PPTX
Sql(structured query language)
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
PPT
Mysql
PPTX
Entity Relationship Modelling
PDF
Triggers in SQL | Edureka
PPTX
Chapter 1 introduction to sql server
PPTX
Presentation slides of Sequence Query Language (SQL)
PPTX
Basic SQL and History
DOC
PDF
Chapter 4 Structured Query Language
PPT
Sql server T-sql basics ppt-3
PPTX
introdution to SQL and SQL functions
PPTX
Group By, Order By, and Aliases in SQL
PPTX
Oracle Database Sequence
SQL - DML and DDL Commands
Sql and Sql commands
Bootcamp sql fundamental
Sql(structured query language)
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
Mysql
Entity Relationship Modelling
Triggers in SQL | Edureka
Chapter 1 introduction to sql server
Presentation slides of Sequence Query Language (SQL)
Basic SQL and History
Chapter 4 Structured Query Language
Sql server T-sql basics ppt-3
introdution to SQL and SQL functions
Group By, Order By, and Aliases in SQL
Oracle Database Sequence
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
PPTX
06.01 sql select distinct
PDF
Sql tutorial
DOC
Module 3
PDF
SQL notes 1.pdf
PPTX
PPTX
PDF
Sql overview-1232931296681161-1
PPTX
SQL Query
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
06.01 sql select distinct
Sql tutorial
Module 3
SQL notes 1.pdf
Sql overview-1232931296681161-1
SQL Query

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Introduction and Scope of Bichemistry.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
English Language Teaching from Post-.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
Microbial disease of the cardiovascular and lymphatic systems
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
Basic Mud Logging Guide for educational purpose
Week 4 Term 3 Study Techniques revisited.pptx
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Introduction and Scope of Bichemistry.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
English Language Teaching from Post-.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
The Final Stretch: How to Release a Game and Not Die in the Process.
Microbial diseases, their pathogenesis and prophylaxis
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
NOI Hackathon - Summer Edition - GreenThumber.pptx

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!