SlideShare a Scribd company logo
SQL
Prepared By
Niloy Saha
Dipongker Sen
Dept. Of Computer Science &
Engineering
Hamdard University Bangladesh
Data Definition language(DDL)
 CREATE,ALTER,DROP
Data Manipulation Language(DML)
 INSERT,DELETE,UPDATE
Data Query Language(DQL)
 SELECT
Operations on Table in a Database
o Set Theory Operations:
 Union, Intersection, Difference and Cartesian product.
o Specific Relational Operations:
 Selection, Projection, Join, Division
CONTENTS
CREATE TABLE TABLE_NAME
(
COLUMN_NAME1 DATA_TYPE(SIZE),
COLUMN_NAME2 DATA_TYPE(SIZE),
COLUMN_NAME3 DATA_ TYPE(SIZE),
…
PRIMARY KEY(COLUMN_NAME1 ));
Data Definition language(DDL)
CREATE,ALTER,DROP
Example:
CREATE TABLE BRANCH
(
BRANCH_NAME CHAR(20),
BRANCH_CITY CHAR(20),
ASSETS INT,
PRIMARY KEY(BRANCH_NAME));
 CREATE TABLE CONSTRUCT
SQL ALTER TABLE SYNTAX
 To Add A Column In A Table
ALTER TABLE TABLE_NAME
ADD COLUMN_NAME DATATYPE;
Data Definition language(DDL)
CREATE,ALTER,DROP
Example:
ALTER TABLE PERSONS
ADD COLUMN SALARY INT;
SQL ALTER TABLE SYNTAX
 To DROP A Column In A Table
ALTER TABLE TABLE_NAME
DROP COLUMN COLUMN_NAME;
Data Definition language(DDL)
CREATE,ALTER,DROP
Example:
ALTER TABLE PERSONS
DROP COLUMN COLUMN SALARY;
 THE DROP TABLE STATEMENT
DROP TABLE TABLE_NAME;
Data Definition language(DDL)
CREATE,ALTER,DROP
Example:
DROP TABLE PERSONS;
 SQL SELECT Syntax
SELECT * FROM TABLE_NAME;
&
SELECT COLUMN1_NAME,COLUMN2_NAME
FROM TABLE_NAME;
Data Query Language(DQL)
SELECT
 THE SQL INSERT INTO STATEMENT
INSERT INTO TABLE_NAME (COLUMN1,COLUMN2,...)
VALUES (VALUE1,VALUE2,...);
Data Manipulation Language(DML)
INSERT,DELETE,UPDATE
 THE SQL DELETE STATEMENT
DELETE FROM TABLE_NAME
WHERE COLUMN_NAME=VALUE;
Data Manipulation Language(DML)
INSERT,DELETE,UPDATE
 THE SQL UPDATE STATEMENT
UPDATE TABLE_NAME
SET COLUMN1=VALUE1,COLUMN2=VALUE2,...
WHERE SOME_COLUMN=SOME_VALUE;
Data Manipulation Language(DML)
INSERT,DELETE,UPDATE
Set Theory Operations
Relation: R
First Last Age
Bill Smith 22
Sally Green 28
Mary Keen 23
Tony Jones 32
Relation : S
First Last
A
ge
Forrest Gump 36
Sally Green 28
DonJuan DeMarco 27
 Consider the following relations R and S
First Last Age
Bill Smith 22
Sally Green 28
Mary Keen 23
Tony Jones 32
Forrest Gump 36
DonJuan DeMarco 27
 UNION: R U S
 INTERSECTION: R ∩ S
First Last Age
Sally Green 28
 Difference: R - S
First Last Age
Bill Smith 22
Mary Keen 23
Tony Jones 32
Set Theory Operations
 Cartesian Product: Produce all combinations of
tuples from two relations.
Relation: R
First Last Age
Bill Smith 22
Mary Keen 23
Tony Jones 32
Relation: S
Dinner Dessert
Steak Ice Cream
Lobster
Cheesecak
e
Result: R X S
First Last Age Dinner Dessert
Bill Smith 22 Steak Ice Cream
Bill Smith 22 Lobster Cheesecake
Mary Keen 23 Steak Ice Cream
Mary Keen 23 Lobster Cheesecake
Tony Jones 32 Steak Ice Cream
Tony Jones 32 Lobster Cheesecake
Thank You


More Related Content

Similar to database concepts

Lab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer labLab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer lab
MUHAMMADANSAR76
 
6_SQL.pdf
6_SQL.pdf6_SQL.pdf
6_SQL.pdf
LPhct2
 
Getting Started with SQL Language.pptx
Getting Started with SQL Language.pptxGetting Started with SQL Language.pptx
Getting Started with SQL Language.pptx
Cecilia Brusatori
 
Sql
SqlSql
Mca ii-dbms- u-iii-sql concepts
Mca ii-dbms- u-iii-sql conceptsMca ii-dbms- u-iii-sql concepts
Mca ii-dbms- u-iii-sql concepts
Rai University
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
SAIFKHAN41507
 
Sql intro
Sql introSql intro
Sql introglubox
 
SQL.ppt
SQL.pptSQL.ppt
SQL.ppt
Ranjit273515
 
Ra Revision
Ra RevisionRa Revision
Ra Revision
hithammohamed
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql newSANTOSH RATH
 
Pig statements
Pig statementsPig statements
Pig statements
Ganesh Sanap
 
Data Management in R
Data Management in RData Management in R
Data Management in R
Sankhya_Analytics
 
Sql server building a database ppt 12
Sql server building a database ppt 12Sql server building a database ppt 12
Sql server building a database ppt 12
Vibrant Technologies & Computers
 

Similar to database concepts (20)

Lab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer labLab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer lab
 
6_SQL.pdf
6_SQL.pdf6_SQL.pdf
6_SQL.pdf
 
Getting Started with SQL Language.pptx
Getting Started with SQL Language.pptxGetting Started with SQL Language.pptx
Getting Started with SQL Language.pptx
 
Db1 lecture4
Db1 lecture4Db1 lecture4
Db1 lecture4
 
Sql
SqlSql
Sql
 
Mca ii-dbms- u-iii-sql concepts
Mca ii-dbms- u-iii-sql conceptsMca ii-dbms- u-iii-sql concepts
Mca ii-dbms- u-iii-sql concepts
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
Sql statements function join
Sql statements function joinSql statements function join
Sql statements function join
 
07.04 joins
07.04 joins07.04 joins
07.04 joins
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
Relational+algebra (1)
Relational+algebra (1)Relational+algebra (1)
Relational+algebra (1)
 
Unit03 dbms
Unit03 dbmsUnit03 dbms
Unit03 dbms
 
Sql intro
Sql introSql intro
Sql intro
 
SQL.ppt
SQL.pptSQL.ppt
SQL.ppt
 
Ra Revision
Ra RevisionRa Revision
Ra Revision
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
Pig statements
Pig statementsPig statements
Pig statements
 
Data Management in R
Data Management in RData Management in R
Data Management in R
 
Sql server building a database ppt 12
Sql server building a database ppt 12Sql server building a database ppt 12
Sql server building a database ppt 12
 

Recently uploaded

6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx
benykoy2024
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
dxobcob
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 

Recently uploaded (20)

6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 

database concepts

  • 1. SQL Prepared By Niloy Saha Dipongker Sen Dept. Of Computer Science & Engineering Hamdard University Bangladesh
  • 2. Data Definition language(DDL)  CREATE,ALTER,DROP Data Manipulation Language(DML)  INSERT,DELETE,UPDATE Data Query Language(DQL)  SELECT Operations on Table in a Database o Set Theory Operations:  Union, Intersection, Difference and Cartesian product. o Specific Relational Operations:  Selection, Projection, Join, Division CONTENTS
  • 3. CREATE TABLE TABLE_NAME ( COLUMN_NAME1 DATA_TYPE(SIZE), COLUMN_NAME2 DATA_TYPE(SIZE), COLUMN_NAME3 DATA_ TYPE(SIZE), … PRIMARY KEY(COLUMN_NAME1 )); Data Definition language(DDL) CREATE,ALTER,DROP Example: CREATE TABLE BRANCH ( BRANCH_NAME CHAR(20), BRANCH_CITY CHAR(20), ASSETS INT, PRIMARY KEY(BRANCH_NAME));  CREATE TABLE CONSTRUCT
  • 4. SQL ALTER TABLE SYNTAX  To Add A Column In A Table ALTER TABLE TABLE_NAME ADD COLUMN_NAME DATATYPE; Data Definition language(DDL) CREATE,ALTER,DROP Example: ALTER TABLE PERSONS ADD COLUMN SALARY INT;
  • 5. SQL ALTER TABLE SYNTAX  To DROP A Column In A Table ALTER TABLE TABLE_NAME DROP COLUMN COLUMN_NAME; Data Definition language(DDL) CREATE,ALTER,DROP Example: ALTER TABLE PERSONS DROP COLUMN COLUMN SALARY;
  • 6.  THE DROP TABLE STATEMENT DROP TABLE TABLE_NAME; Data Definition language(DDL) CREATE,ALTER,DROP Example: DROP TABLE PERSONS;
  • 7.  SQL SELECT Syntax SELECT * FROM TABLE_NAME; & SELECT COLUMN1_NAME,COLUMN2_NAME FROM TABLE_NAME; Data Query Language(DQL) SELECT
  • 8.  THE SQL INSERT INTO STATEMENT INSERT INTO TABLE_NAME (COLUMN1,COLUMN2,...) VALUES (VALUE1,VALUE2,...); Data Manipulation Language(DML) INSERT,DELETE,UPDATE
  • 9.  THE SQL DELETE STATEMENT DELETE FROM TABLE_NAME WHERE COLUMN_NAME=VALUE; Data Manipulation Language(DML) INSERT,DELETE,UPDATE
  • 10.  THE SQL UPDATE STATEMENT UPDATE TABLE_NAME SET COLUMN1=VALUE1,COLUMN2=VALUE2,... WHERE SOME_COLUMN=SOME_VALUE; Data Manipulation Language(DML) INSERT,DELETE,UPDATE
  • 11. Set Theory Operations Relation: R First Last Age Bill Smith 22 Sally Green 28 Mary Keen 23 Tony Jones 32 Relation : S First Last A ge Forrest Gump 36 Sally Green 28 DonJuan DeMarco 27  Consider the following relations R and S First Last Age Bill Smith 22 Sally Green 28 Mary Keen 23 Tony Jones 32 Forrest Gump 36 DonJuan DeMarco 27  UNION: R U S  INTERSECTION: R ∩ S First Last Age Sally Green 28
  • 12.  Difference: R - S First Last Age Bill Smith 22 Mary Keen 23 Tony Jones 32 Set Theory Operations  Cartesian Product: Produce all combinations of tuples from two relations. Relation: R First Last Age Bill Smith 22 Mary Keen 23 Tony Jones 32 Relation: S Dinner Dessert Steak Ice Cream Lobster Cheesecak e Result: R X S First Last Age Dinner Dessert Bill Smith 22 Steak Ice Cream Bill Smith 22 Lobster Cheesecake Mary Keen 23 Steak Ice Cream Mary Keen 23 Lobster Cheesecake Tony Jones 32 Steak Ice Cream Tony Jones 32 Lobster Cheesecake