SlideShare a Scribd company logo
Structured Query Language
Prepared By:
Reema Agrawal
Asst Professor
MERI
SQL
 Structured Query language is a language that
provides an interface to database systems.
 SQL was developed by IBM in 1970.
Features Of SQL:
 SQL can be used by a range of users, including
those with little or no programming experience.
 It reduces the amount of time required for
creating and maintaining systems.
 It is an English like language.
Data types:
 SQL data type is an attribute that specifies type
of data of any object.
 Each column, variable and expression has
related data type in SQL.
 These are of several forms and sizes
Data types:
 Char- Maximum length of 255 characters. Alphabets
only.
 Varchar- Maximum of 8,000 characters.
Alphanumeric
 Int- Numeric and negative
 Float- Numeric, decimal and negative integers
 Number- It is of floating type. Number (P,S). P-
determines the maximum length of the data.
S- Number of places to the right of the decimal.
CREATE DATABASE
 Create DATABASE databasename;
The CREATE TABLE command
 The CREATE TABLE command defines each
column of the table uniquely.
 Each column has a minimum of three attributes
– a name, datatype and size.
 Each table column definition is separated from
the other by a comma.
 Finally, the SQL statement is terminated with a
semi colon.
The CREATE TABLE command
Syntax:
CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);
Inserting Data Into Tables
 Once a table is created, the most natural thing to
do is load this table with data to be manipulated
later.
Syntax:
INSERT INTO <tablename> values (<‘expression
1’>, <‘expression2’>);
For specific columns:
INSERT INTO <tablename> (<columnname1>,
<columnname2>)
values (<‘expression 1’>, <‘expression2’>);
Table Name: Employee
Emp_ID Name Designation Location Salary
A10141 Ajay Manager Delhi 75000
A10142 Rahul Executive Delhi 55000
A10143 Shruti Manager Bangalore 80000
A10144 Lokesh VP Bangalore 100000
A10145 Tripti Sales Mumbai 40000
Table Name: Student
Student_Rol
l No
Name Course Location Total Marks
10126734 Rahul BBA Delhi 500
10117834 Tarun BBA Delhi 586
10128734 Shruti MBA Delhi 540
10118834 Lalit BCA Delhi 523
10126834 Ajay BBA Delhi 596
10118934 Parul MBA Delhi 561
Viewing Data In the Tables:
 Once the data has been inserted into a table, the
next logical operation would be to view what has
been inserted.
 The SELECT command is used to retrieve rows
selected from one or more tables.
 To view the whole table
 Selected columns and all rows
 Selected rows and all columns
 Selected columns and selected rows
Viewing Data In the Tables:
 To view the whole table:
Syntax:
SELECT * FROM <tablename>;
• To view selected columns and all rows
Syntax:
SELECT <columnname1>, <columnname2> FROM
<tablename>;
Viewing Data In the Tables:
 Selected rows and all columns
Syntax:
SELECT * FROM <tablename> WHERE <condition>;
• Selected rows and selected columns
Syntax:
SELECT <columnname1>, <columnname2> FROM
<Tablename> WHERE <condition> ;
Eliminating Duplicate Rows
 Specific columns
SELECT DISTINCT <columnname1>,
<columnname2> from <tablename>;
 Entire rows
SELECT DISTINCT * from <tablename>;
Sorting Data In a table
 The rows retrieved from the table will be sorted
in either ascending or descending order
depending on the condition specified in the
SELECT sentence.
Syntax:
Select * from <Tablename> order by
<columnname1>;
Select * from <Tablename> order by
<columnname1>desc;
DELETE OPERATION
 The DELETE in SQL is used to remove either all
the rows from a table or a set of rows of a table.
 All the rows:
Syntax:
DELETE FROM <TableName>;
• A set of rows from table:
Syntax:
DELETE FROM <TableName> WHERE <condition>;
ALTER TABLE
 Adding new columns
ALTER TABLE <tablename>
ADD(<newcolumnname><datatype> (<size>),
<newcolumnname><datatype> (<size>));
 Dropping column
ALTER TABLE <tablename> DROP COLUMN
<columnname>;
 Modifying columns
ALTER TABLE <tablename> MODIFY
(<columnname> <Newdatatype>(<Newsize>));
Updating The contents Of a table:
 The UPDATE command is used to change or
modify data values in a table.
 All the rows:
UPDATE <TableName> SET
<columnname1>=<expression1>,
<columnname2>=<expression2>;
• A selected set of rows
UPDATE <TableName> SET
<columnname1>=<expression1>,
<columnname2>=<expression2> where
<condition>;
Renaming, Truncating And
Dropping Tables:
 Renaming tables:
RENAME <TableName> to <NewTableName>;
• Truncating tables:
TRUNCATE TABLE <TableName>;
• Dropping tables:
DROP TABLE <TableName>;
Some Queries:
 SELECT * FROM student WHERE name LIKE '%John%‘
(with either first or last name as JOHN)
 SELECT * FROM student WHERE name LIKE 'John%‘
(with first name JOHN)
 SELECT * FROM student WHERE name LIKE '%John‘
(with last name JOHN)
 SELECT * FROM student WHERE name LIKE '%a%' AND
name LIKE '%e%‘ (with either first alphabet as a or e)
SQL. It education ppt for reference  sql process coding

More Related Content

Similar to SQL. It education ppt for reference sql process coding (20)

DOCX
COMPUTERS SQL
Rc Os
 
PPTX
DBMSLab_SQL_4thsem_CI_17163544545446962.pptx
dgfs55437
 
PPTX
2..basic queries.pptx
MalaikaRahatQurashi
 
PPTX
SQL
Shyam Khant
 
PPTX
SQL Presentation & explaination short I.pptx
lankanking4
 
PPTX
Its about a sql topic for basic structured query language
IMsKanchanaI
 
DOC
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
Newyorksys.com
 
DOC
Oracle
Rajeev Uppala
 
PPT
MY SQL
sundar
 
PDF
MYSQL-database different functions pptx.pdf
viluThakkar
 
PPTX
Introduction to sql new
SANTOSH RATH
 
PPTX
Commands
Ayushi Goyal
 
PPTX
SAMPLE QUESTION PAPER (THEORY) CLASS: XII SESSION: 2024-25 COMPUTER SCIENCE...
MafnithaKK
 
PPTX
SQL.pptx SAMPLE QUESTION PAPER (THEORY) CLASS: XII SESSION: 2024-25 COMPUTE...
MafnithaKK
 
PPT
UNIT2.ppt
SaurabhLokare1
 
PDF
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
zmulani8
 
PDF
Class XII-UNIT III - SQL and MySQL Notes_0.pdf
rohithlingineni1
 
PPT
Sql – Structured Query Language
pandey3045_bit
 
PPTX
SQL Tutorial for Beginners
Abdelhay Shafi
 
PPTX
Sql slid
pacatarpit
 
COMPUTERS SQL
Rc Os
 
DBMSLab_SQL_4thsem_CI_17163544545446962.pptx
dgfs55437
 
2..basic queries.pptx
MalaikaRahatQurashi
 
SQL Presentation & explaination short I.pptx
lankanking4
 
Its about a sql topic for basic structured query language
IMsKanchanaI
 
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
Newyorksys.com
 
MY SQL
sundar
 
MYSQL-database different functions pptx.pdf
viluThakkar
 
Introduction to sql new
SANTOSH RATH
 
Commands
Ayushi Goyal
 
SAMPLE QUESTION PAPER (THEORY) CLASS: XII SESSION: 2024-25 COMPUTER SCIENCE...
MafnithaKK
 
SQL.pptx SAMPLE QUESTION PAPER (THEORY) CLASS: XII SESSION: 2024-25 COMPUTE...
MafnithaKK
 
UNIT2.ppt
SaurabhLokare1
 
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
zmulani8
 
Class XII-UNIT III - SQL and MySQL Notes_0.pdf
rohithlingineni1
 
Sql – Structured Query Language
pandey3045_bit
 
SQL Tutorial for Beginners
Abdelhay Shafi
 
Sql slid
pacatarpit
 

More from aditipandey498628 (6)

PPTX
Managementprocess and operationalbehavior.pptx
aditipandey498628
 
PPTX
Project management Education purpose (1).pptx
aditipandey498628
 
PPTX
CYBER CRIME sujal education it related ppt. Pptx
aditipandey498628
 
PPTX
Corporate finance and emerging issues FINAL PPT.pptx
aditipandey498628
 
PDF
wepik-dream-11-digital-marketing-strategy-unveiled-20240413073458ENgt[1].pdf
aditipandey498628
 
PPT
CAPITAL STRUCTURE ppt bba ipu business , financial management , capital struc...
aditipandey498628
 
Managementprocess and operationalbehavior.pptx
aditipandey498628
 
Project management Education purpose (1).pptx
aditipandey498628
 
CYBER CRIME sujal education it related ppt. Pptx
aditipandey498628
 
Corporate finance and emerging issues FINAL PPT.pptx
aditipandey498628
 
wepik-dream-11-digital-marketing-strategy-unveiled-20240413073458ENgt[1].pdf
aditipandey498628
 
CAPITAL STRUCTURE ppt bba ipu business , financial management , capital struc...
aditipandey498628
 
Ad

Recently uploaded (20)

PPTX
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PDF
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PPT
Testing and final inspection of a solar PV system
MuhammadSanni2
 
PPTX
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
Testing and final inspection of a solar PV system
MuhammadSanni2
 
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Ad

SQL. It education ppt for reference sql process coding

  • 1. Structured Query Language Prepared By: Reema Agrawal Asst Professor MERI
  • 2. SQL  Structured Query language is a language that provides an interface to database systems.  SQL was developed by IBM in 1970.
  • 3. Features Of SQL:  SQL can be used by a range of users, including those with little or no programming experience.  It reduces the amount of time required for creating and maintaining systems.  It is an English like language.
  • 4. Data types:  SQL data type is an attribute that specifies type of data of any object.  Each column, variable and expression has related data type in SQL.  These are of several forms and sizes
  • 5. Data types:  Char- Maximum length of 255 characters. Alphabets only.  Varchar- Maximum of 8,000 characters. Alphanumeric  Int- Numeric and negative  Float- Numeric, decimal and negative integers  Number- It is of floating type. Number (P,S). P- determines the maximum length of the data. S- Number of places to the right of the decimal.
  • 6. CREATE DATABASE  Create DATABASE databasename;
  • 7. The CREATE TABLE command  The CREATE TABLE command defines each column of the table uniquely.  Each column has a minimum of three attributes – a name, datatype and size.  Each table column definition is separated from the other by a comma.  Finally, the SQL statement is terminated with a semi colon.
  • 8. The CREATE TABLE command Syntax: CREATE TABLE table_name ( column_name1 data_type(size), column_name2 data_type(size), column_name3 data_type(size), .... );
  • 9. Inserting Data Into Tables  Once a table is created, the most natural thing to do is load this table with data to be manipulated later. Syntax: INSERT INTO <tablename> values (<‘expression 1’>, <‘expression2’>); For specific columns: INSERT INTO <tablename> (<columnname1>, <columnname2>) values (<‘expression 1’>, <‘expression2’>);
  • 10. Table Name: Employee Emp_ID Name Designation Location Salary A10141 Ajay Manager Delhi 75000 A10142 Rahul Executive Delhi 55000 A10143 Shruti Manager Bangalore 80000 A10144 Lokesh VP Bangalore 100000 A10145 Tripti Sales Mumbai 40000
  • 11. Table Name: Student Student_Rol l No Name Course Location Total Marks 10126734 Rahul BBA Delhi 500 10117834 Tarun BBA Delhi 586 10128734 Shruti MBA Delhi 540 10118834 Lalit BCA Delhi 523 10126834 Ajay BBA Delhi 596 10118934 Parul MBA Delhi 561
  • 12. Viewing Data In the Tables:  Once the data has been inserted into a table, the next logical operation would be to view what has been inserted.  The SELECT command is used to retrieve rows selected from one or more tables.  To view the whole table  Selected columns and all rows  Selected rows and all columns  Selected columns and selected rows
  • 13. Viewing Data In the Tables:  To view the whole table: Syntax: SELECT * FROM <tablename>; • To view selected columns and all rows Syntax: SELECT <columnname1>, <columnname2> FROM <tablename>;
  • 14. Viewing Data In the Tables:  Selected rows and all columns Syntax: SELECT * FROM <tablename> WHERE <condition>; • Selected rows and selected columns Syntax: SELECT <columnname1>, <columnname2> FROM <Tablename> WHERE <condition> ;
  • 15. Eliminating Duplicate Rows  Specific columns SELECT DISTINCT <columnname1>, <columnname2> from <tablename>;  Entire rows SELECT DISTINCT * from <tablename>;
  • 16. Sorting Data In a table  The rows retrieved from the table will be sorted in either ascending or descending order depending on the condition specified in the SELECT sentence. Syntax: Select * from <Tablename> order by <columnname1>; Select * from <Tablename> order by <columnname1>desc;
  • 17. DELETE OPERATION  The DELETE in SQL is used to remove either all the rows from a table or a set of rows of a table.  All the rows: Syntax: DELETE FROM <TableName>; • A set of rows from table: Syntax: DELETE FROM <TableName> WHERE <condition>;
  • 18. ALTER TABLE  Adding new columns ALTER TABLE <tablename> ADD(<newcolumnname><datatype> (<size>), <newcolumnname><datatype> (<size>));  Dropping column ALTER TABLE <tablename> DROP COLUMN <columnname>;  Modifying columns ALTER TABLE <tablename> MODIFY (<columnname> <Newdatatype>(<Newsize>));
  • 19. Updating The contents Of a table:  The UPDATE command is used to change or modify data values in a table.  All the rows: UPDATE <TableName> SET <columnname1>=<expression1>, <columnname2>=<expression2>; • A selected set of rows UPDATE <TableName> SET <columnname1>=<expression1>, <columnname2>=<expression2> where <condition>;
  • 20. Renaming, Truncating And Dropping Tables:  Renaming tables: RENAME <TableName> to <NewTableName>; • Truncating tables: TRUNCATE TABLE <TableName>; • Dropping tables: DROP TABLE <TableName>;
  • 21. Some Queries:  SELECT * FROM student WHERE name LIKE '%John%‘ (with either first or last name as JOHN)  SELECT * FROM student WHERE name LIKE 'John%‘ (with first name JOHN)  SELECT * FROM student WHERE name LIKE '%John‘ (with last name JOHN)  SELECT * FROM student WHERE name LIKE '%a%' AND name LIKE '%e%‘ (with either first alphabet as a or e)