SlideShare a Scribd company logo
Structured Query Language
Prof. K ADISESHA (Ph. D)
Introduction
Architecture of SQL
SQL Commands
SQL Data types
Data Warehouse
2Structured Query Language
Prof. K. Adisesha
Structured Query Language
Prof. K. Adisesha (Ph. D)
3
Structured Query Language (SQL):
SQL is Structured Query Language, which is a computer language for
storing, manipulating and retrieving data stored in relational database.
 Structured Query Language and it helps to make practice on SQL commands which
provides immediate results.
 SQL is the standard language for Relation Database System.
 All relational database management systems like MySQL, MS Access, and Oracle,
Sybase, Informix, and SQL Server use SQL as standard database language.
Structured Query Language
Prof. K. Adisesha (Ph. D)
4
A Brief History of SQL:
A Relational database management system (RDBMS) is a database management
system (DBMS) that is based on the relational model as introduced by E. F. Codd.
 1970 − Dr. Edgar F. "Ted" Codd of IBM is known as the father of relational
databases. He described a relational model for databases.
 1974 − Structured Query Language appeared.
 1978 − IBM worked to develop Codd's ideas and released a product named System/R.
 1986 − IBM developed the first prototype of relational database and standardized by
ANSI. The first relational database was released by Relational Software which later
came to be known as Oracle.
Structured Query Language
Prof. K. Adisesha (Ph. D)
5
Structured Query Language (SQL):
SQL is Structured Query Language, which is a computer language for
storing, manipulating and retrieving data stored in relational database.
Structured Query Language
Prof. K. Adisesha (Ph. D)
6
Structured Query Language (SQL):
When you are executing an SQL command for any RDBMS, the system determines the
best way to carry out your request and SQL engine figures out how to interpret the task.
 There are various components included in the process.
 These components are:
 Query Dispatcher
 Optimization Engines
 Classic Query Engine
 SQL Query Engine
Structured Query Language
Prof. K. Adisesha (Ph. D)
7
Need for SQL:
SQL is Structured Query Language used for storing, manipulating and
retrieving data stored in relational database.
 Allows users to create and drop databases and tables.
 Allows users to describe the data.
 Allows users to define the data in database and manipulate that data.
 Allows users to access data in relational database management systems.
 Allows embedding within other languages using SQL modules, libraries & pre-
compilers.
 Allows users to set permissions on tables, procedures, and views
Structured Query Language
Prof. K. Adisesha (Ph. D)
8
SQL Commands:
The standard SQL commands to interact with relational databases are CREATE,
SELECT, INSERT, UPDATE, DELETE and DROP.
 These commands can be classified into groups based on their nature:
 DDL - Data Definition Language
 DML - Data Manipulation Language
 DCL - Data Control Language
 TCL – Transaction Control Language
Structured Query Language
Prof. K. Adisesha (Ph. D)
9
Data Definition Language (DDL):
DDL defines the conceptual schema providing a link between the logical and the
physical structure of the database.
 The functions of the Data Definition Language (DDL) are:
 It defines the physical characteristics of each record, filed in the record, field’s data type,
field's length, field’s logical name and also specify relationship among those records.
 Describes the schema and subschema.
 Indicates the keys of records.
 Provides data security measures.
 Provides for the logical and physical data independence.
Structured Query Language
Prof. K. Adisesha (Ph. D)
10
Data Definition Language (DDL):
DDL defines the conceptual schema providing a link between the logical and
the physical structure of the database.
 Few of the basic commands for DDL are:
Command Description
CREATE
Creates a new table, a view of a table, or other object in the
database.
ALTER Modifies an existing database object, such as a table
DROP
Deletes an entire table, a view of a table or other objects in the
database.
RENAME Renames an existing database object, such as a table
Structured Query Language
Prof. K. Adisesha (Ph. D)
11
Data Manipulation Language(DML):
DML provides the data manipulation techniques like selection, insertion,
deletion, updation, modification, replacement, retrieval, sorting and display of
data or records.
 DML facilitates use of relationship between the records.
 DML provides for independence of programming languages by supporting
several high-level programming languages like COBOL, PL/1 and C++.:
Structured Query Language
Prof. K. Adisesha (Ph. D)
12
Data Manipulation Language(DML):
DML provides the data manipulation techniques like selection, insertion,
deletion, updation, modification, replacement, retrieval, sorting and display of
data or records.
 Few of the basic commands for DML are:
Command Description
INSERT Creates a record.
UPDATE Modifies records.
DELETE Deletes records.
Structured Query Language
Prof. K. Adisesha (Ph. D)
13
Data Control Language (DCL):
These SQL commands are used for providing security to database objects.
 Few of the basic commands for DCL are:
Command Description
GRANT
Gives a privilege to user.
Such as setting Passwords to Database Users
REVOKE Takes back privileges granted from user.
Structured Query Language
Prof. K. Adisesha (Ph. D)
14
Transaction Control Language (TCL):
It includes commands to control the transactions in a database system.
 Few of the basic commands for TCL are:
Command Description
SELECT Retrieves certain records from one or more tables
syntax:
>SELECT * FROM table_name;
Data Types in SQL
Prof. K. Adisesha (Ph. D)
15
Data Types in SQL:
 The following are the most common data types of SQL
Data Data Type From To
Numeric
int -2,147,483,648 2,147,483,647
numeric -10^38 +1 10^38 -1
float -1.79E + 308 1.79E + 308
real -3.40E + 38 3.40E + 38
String
Char
Maximum length of 8,000
characters
Fixed length non-Unicode characters
varchar Maximum of 8,000 characters. Variable-length non-Unicode data
Data Types in SQL
Prof. K. Adisesha (Ph. D)
16
Data Types in SQL:
 The following are the most common data types of SQL
Data Data Type From To
Date/
Time
datetime Jan 1, 1753 Dec 31, 9999
smalldatetime Jan 1, 1900 Jun 6, 2079
date Stores a date like June 30, 2020
time Stores a time of day like 12:30 P.M.
timestamp
Stores a database-wide unique number that gets updated every
time a row gets updated
Operator in SQL
Prof. K. Adisesha (Ph. D)
17
Operator in SQL:
An operator is a reserved word or a character used primarily in an SQL
statement's WHERE clause to perform operation(s), such as comparisons and
arithmetic operations.
 These Operators are used to specify conditions in an SQL statement and to
serve as conjunctions for multiple conditions in a statement.
 Arithmetic operators
 Comparison operators
 Logical operators
 Operators used to negate conditions
Arithmetic Operators
Prof. K. Adisesha (Ph. D)
18
Arithmetic Operators in SQL:
 The following are the most common Arithmetic Operators of SQL: Given a=10, b=20
Operator Description Example
(Addition) + Adds values on either side of the operator a + b will give 30
(Subtraction) - Subtracts right hand operand from left hand operand. a - b will give -10
(Multiplication) * Multiplies values on either side of the operator. a * b will give 200
(Division) / Divides left hand operand by right hand operand. b / a will give 2
(Modulus) %
Divides left hand operand by right hand operand and
returns remainder.
b % a will give 0
Operator Description Example
=
Checks if the values of two operands are equal or not, if yes then
condition becomes true.
(a = b) is False
!= , < >
Checks if the values of two operands are equal or not, if values are
not equal then condition becomes true..
(a != b) is true
(a <> b) is true
>, >=
Checks if the value of left operand is greater than the value of right
operand, if yes then condition becomes true.
(a > b) is False
(a >= b) is False
< , <=
Checks if the value of left operand is less than or equal to the value of
right operand, if yes then condition becomes true.
(a < b) is true
(a <= b) is true
! > , !<
Checks if the value of left operand is not less than the value of right
operand, if yes then condition becomes true.
(a !< b) is false
(a !> b) is true
Comparison Operators
Prof. K. Adisesha (Ph. D)
19
Comparison Operators in SQL:
 The following are the most common Comparison Operators of SQL: Given a=10, b=20
Logical Operators
Prof. K. Adisesha (Ph. D)
20
Logical Operators in SQL:
 The following are the most common Logical Operators of SQL:
Operator Description
ALL, ANY
The ALL operator is used to compare a value to all values in another value set.
The ANY operator is used to compare a value to any applicable value in the list on condition
AND, OR The AND, OR operator allows the existence of multiple conditions in an SQL statement's
NOT The NOT operator reverses the meaning of the logical operator with which it is used
BETWEEN
The BETWEEN operator is used to search for values that are within a set of values, given the
minimum value and the maximum value.
EXISTS
The EXISTS operator is used to search for the presence of a row in a specified table that meets a
certain criterion.
UNIQUE he UNIQUE operator searches every row of a specified table for uniqueness
SQL - Expressions
Prof. K. Adisesha (Ph. D)
21
Expressions in SQL:
An expression is a combination of one or more values, operators and SQL
functions that evaluate to a value..
 These SQL EXPRESSIONs are like formulae and they are written in query
language.
 There are different types of SQL expressions are:
 Boolean
 Numeric
 Date
SQL - Expressions
Prof. K. Adisesha (Ph. D)
22
Boolean Expressions in SQL:
SQL Boolean Expressions fetch the data based on matching a single value.
 Following is the syntax:
SELECT column1, column2, .. columnN
FROM table_name
WHERE SINGLE VALUE MATCHING EXPRESSION;
 Example showing the usage of various SQL Boolean Expressions −
SQL> SELECT * FROM CUSTOMERS WHERE SALARY = 20000;
SQL - Expressions
Prof. K. Adisesha (Ph. D)
23
Numeric Expression in SQL:
These expressions are used to perform any mathematical operation in any query.
 The numerical expression is used for a mathematical expression or any formula
 Following is the syntax:
SELECT numerical expression as OPERATION_NAME
[FROM table_name
WHERE CONDITION] ;
 Example showing the usage of various SQL Numeric Expressions −
SQL> SELECT (15 + 6) AS ADDITION;
SQL> SELECT COUNT(*) AS "RECORDS" FROM CUSTOMERS;
SQL - Expressions
Prof. K. Adisesha (Ph. D)
24
Date Expressions in SQL:
These expressions are used to calculate and return the Date and Time operation in any
query.
 Date Expressions return current system date and time values
 Following is the syntax:
SQL> SELECT CURRENT_TIMESTAMP;
 Example showing the usage of various SQL Numeric Expressions −
SQL> SELECT GETDATE();
SQL - Database
Prof. K. Adisesha (Ph. D)
25
Managing Database in SQL:
Always the database name should be unique within the RDBMS
CREATE Database:
 The SQL CREATE DATABASE statement is used to create a new SQL database
 Syntax: CREATE DATABASE DatabaseName;
DROP or DELETE Database
 The SQL DROP DATABASE statement is used to drop an existing database in SQL schema
 Syntax: DROP DATABASE DatabaseName;
SELECT Database, USE Statement
 The SQL USE statement is used to select any existing database in the SQL schema
 Syntax: USE DatabaseName;
SQL - CREATE Table
Prof. K. Adisesha (Ph. D)
26
SQL CREATE TABLE Statement:
Creating a basic table involves naming the table and defining its columns and each
column's data type.
 The SQL CREATE TABLE statement is used to create a new table
 Syntax: Example:
SQL - Drop Table
Prof. K. Adisesha (Ph. D)
27
SQL Drop TABLE Statement:
The SQL DROP TABLE statement is used to remove a table definition and all the data,
indexes, triggers, constraints and permission specifications for that table..
 The DROP TABLE statement is used to drop an existing table in a database
 Deleting a table will result in loss of complete information stored in the table!
 Syntax: Example:
SQL TRUNCATE TABLE
 The TRUNCATE TABLE statement is used to delete the data inside a table, but not the table
itself.
 Syntax:
SQL - Alter Table
Prof. K. Adisesha (Ph. D)
28
SQL Alter TABLE Statement:
The ALTER TABLE statement is used to add, delete, or modify columns in an existing
table.
ALTER TABLE - ADD Column
 To add a column in a table, use the following syntax:
ALTER TABLE - DROP Column
 To drop a column in a table, use the following syntax:
ALTER TABLE - ALTER/MODIFY Column
 To drop a column in a table, use the following syntax:
SQL Constraints
Prof. K. Adisesha (Ph. D)
29
SQL Create Constraints:
Constraints can be specified when the table is created with the CREATE TABLE
statement, or after the table is created with the ALTER TABLE statement.
 SQL constraints are used to specify rules for the data in a table
 The following constraints are commonly used in SQL:
 NOT NULL - Ensures that a column cannot have a NULL value
 UNIQUE - Ensures that all values in a column are different
 PRIMARY KEY - A combination of a NOT NULL and UNIQUE.
 FOREIGN KEY - Uniquely identifies a row/record in another table
 CHECK - Ensures that all values in a column satisfies a specific condition
 DEFAULT - Sets a default value for a column when no value is specified
SQL Constraints
Prof. K. Adisesha (Ph. D)
30
SQL Create Constraints:
Constraints can be specified when the table is created with the CREATE TABLE
statement, or after the table is created with the ALTER TABLE statement.
 SQL constraints are used to specify rules for the data in a table
 Constraints can be column level or table level.
 Syntax: Example:
SQL INSERT Statement
Prof. K. Adisesha (Ph. D)
31
SQL INSERT INTO Statement:
The INSERT INTO statement is used to insert new records in a table.
 It is possible to write the INSERT INTO statement in two ways.
 The first way specifies both the column names and the values to be inserted
 Syntax:
 If you are adding values for all the columns of the table, you do not need to specify the column
names in the SQL query.
 Syntax:
SQL SELECT Statement
Prof. K. Adisesha (Ph. D)
32
SQL SELECT Statement:
The SELECT statement is used to select data from a database.
 The data returned is stored in a result table, called the result-set.
 If you want to select all the fields available in the table, use the following syntax:
 The SELECT DISTINCT statement is used to return only distinct (different) values..
 Syntax:
 The WHERE clause is used to extract only those records that fulfill a specified condition.
 Syntax:
SQL Joins
Prof. K. Adisesha (Ph. D)
33
SQL JOIN:
A JOIN clause is used to combine rows from two or more tables, based on a related
column between them.
 Different types of the JOINs in SQL:
 (INNER) JOIN: Returns records that have matching values in both tables
 LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records
from the right table
 RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched
records from the left table
 FULL (OUTER) JOIN: Returns all records when there is a match in either left or right
table
SQL Joins
Prof. K. Adisesha (Ph. D)
34
SQL INNER JOIN:
The INNER JOIN keyword selects records that have matching values in both tables.
 (INNER) JOIN: Returns records that have matching values in both tables
SQL Joins
Prof. K. Adisesha (Ph. D)
35
SQL LEFT (OUTER) JOIN:
The LEFT JOIN keyword returns all records from the left table (table1), and the
matched records from the right table (table2).
 The result is NULL from the right side, if there is no match.
 LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from
the right table
SQL Joins
Prof. K. Adisesha (Ph. D)
36
SQL RIGHT JOIN:
The RIGHT JOIN keyword returns all records from the right table (table2), and the
matched records from the left table (table1).
 The result is NULL from the left side, when there is no match.
 RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records
from the left table
SQL Joins
Prof. K. Adisesha (Ph. D)
37
SQL FULL OUTER JOIN:
The FULL OUTER JOIN keyword returns all records when there is a match in left
(table1) or right (table2) table records.
 FULL OUTER JOIN can potentially return very large result-sets.
 FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
SQL ORDER BY
Prof. K. Adisesha (Ph. D)
38
SQL ORDER BY Keyword:
The ORDER BY keyword is used to sort the result-set in ascending or descending
order.
 The ORDER BY keyword sorts the records in ascending order by default. To sort the
records in descending order, use the DESC keyword.
SQL GROUP BY
Prof. K. Adisesha (Ph. D)
39
SQL GROUP BY:
he GROUP BY statement groups rows that have the same values into summary rows,
like "find the number of customers in each country".
 The GROUP BY statement is often used with aggregate functions (COUNT, MAX,
MIN, SUM, AVG) to group the result-set by one or more columns.
SQL Functions
Prof. K. Adisesha (Ph. D)
40
SQL MIN() and MAX() Functions:
The MIN() function returns the smallest value of the selected column.
 MIN() Syntax:
The MAX() function returns the largest value of the selected column.
 MAX() Syntax:
SQL Functions
Prof. K. Adisesha (Ph. D)
41
SQL COUNT(), AVG() and SUM() Functions:
 The COUNT() function returns the number of rows that matches a specified
criterion.
 The AVG() function returns the average value of a numeric column.
 The SUM() function returns the total sum of a numeric column.
Discussion
Prof. K. Adisesha (Ph. D)
42
Queries ?
Prof. K. Adisesha

More Related Content

What's hot

Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
Sabana Maharjan
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
NITISH KUMAR
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
BG Java EE Course
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
Stewart Rogers
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Languagepandey3045_bit
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
Syed Hassan Ali
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
Sharad Dubey
 
SQL commands
SQL commandsSQL commands
SQL commands
GirdharRatne
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
Ishucs
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
Lecture 04 normalization
Lecture 04 normalization Lecture 04 normalization
Lecture 04 normalization emailharmeet
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
Swapnali Pawar
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functionsVikas Gupta
 
DML Commands
DML CommandsDML Commands
SQL
SQLSQL
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
SomeshwarMoholkar
 

What's hot (20)

MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
SQL commands
SQL commandsSQL commands
SQL commands
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
Lecture 04 normalization
Lecture 04 normalization Lecture 04 normalization
Lecture 04 normalization
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
DML Commands
DML CommandsDML Commands
DML Commands
 
SQL
SQLSQL
SQL
 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
 

Similar to Sql ppt

chapter-14-sql-commands.pdf
chapter-14-sql-commands.pdfchapter-14-sql-commands.pdf
chapter-14-sql-commands.pdf
study material
 
The Smartpath Information Systems | BASIC RDBMS CONCEPTS
The Smartpath Information Systems | BASIC RDBMS CONCEPTSThe Smartpath Information Systems | BASIC RDBMS CONCEPTS
The Smartpath Information Systems | BASIC RDBMS CONCEPTS
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)
Nalina Kumari
 
Structure Query Language (SQL).pptx
Structure Query Language (SQL).pptxStructure Query Language (SQL).pptx
Structure Query Language (SQL).pptx
NalinaKumari2
 
Introduction to the Structured Query Language SQL
Introduction to the Structured Query Language SQLIntroduction to the Structured Query Language SQL
Introduction to the Structured Query Language SQL
Harmony Kwawu
 
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
 
SQL2.pptx
SQL2.pptxSQL2.pptx
SQL2.pptx
RareDeath
 
Lecture on DBMS & MySQL.pdf v. C. .
Lecture on DBMS & MySQL.pdf v.  C.     .Lecture on DBMS & MySQL.pdf v.  C.     .
Lecture on DBMS & MySQL.pdf v. C. .
MayankSinghRawat6
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
Danish Mehraj
 
DBMS Part-3.pptx
DBMS Part-3.pptxDBMS Part-3.pptx
DBMS Part-3.pptx
Prof. Dr. K. Adisesha
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)
Rakibul Hasan Pranto
 
sql ppt.pptx
sql ppt.pptxsql ppt.pptx
sql ppt.pptx
ArunT58
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
Divyank Jindal
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
Aditya Kumar Tripathy
 
Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013
Prosanta Ghosh
 

Similar to Sql ppt (20)

chapter-14-sql-commands.pdf
chapter-14-sql-commands.pdfchapter-14-sql-commands.pdf
chapter-14-sql-commands.pdf
 
The Smartpath Information Systems | BASIC RDBMS CONCEPTS
The Smartpath Information Systems | BASIC RDBMS CONCEPTSThe Smartpath Information Systems | BASIC RDBMS CONCEPTS
The Smartpath Information Systems | BASIC RDBMS CONCEPTS
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)
 
Structure Query Language (SQL).pptx
Structure Query Language (SQL).pptxStructure Query Language (SQL).pptx
Structure Query Language (SQL).pptx
 
Introduction to the Structured Query Language SQL
Introduction to the Structured Query Language SQLIntroduction to the Structured Query Language SQL
Introduction to the Structured Query Language SQL
 
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
 
SQL2.pptx
SQL2.pptxSQL2.pptx
SQL2.pptx
 
Lecture on DBMS & MySQL.pdf v. C. .
Lecture on DBMS & MySQL.pdf v.  C.     .Lecture on DBMS & MySQL.pdf v.  C.     .
Lecture on DBMS & MySQL.pdf v. C. .
 
lovely
lovelylovely
lovely
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 
12 SQL
12 SQL12 SQL
12 SQL
 
12 SQL
12 SQL12 SQL
12 SQL
 
DBMS Part-3.pptx
DBMS Part-3.pptxDBMS Part-3.pptx
DBMS Part-3.pptx
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)
 
sql ppt.pptx
sql ppt.pptxsql ppt.pptx
sql ppt.pptx
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013
 

More from Prof. Dr. K. Adisesha

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Prof. Dr. K. Adisesha
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
Prof. Dr. K. Adisesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
Prof. Dr. K. Adisesha
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
Prof. Dr. K. Adisesha
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
Prof. Dr. K. Adisesha
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
Prof. Dr. K. Adisesha
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System-1 by Adi.pdf
Operating System-1 by Adi.pdfOperating System-1 by Adi.pdf
Operating System-1 by Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System-adi.pdf
Operating System-adi.pdfOperating System-adi.pdf
Operating System-adi.pdf
Prof. Dr. K. Adisesha
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdfData_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
Prof. Dr. K. Adisesha
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
Prof. Dr. K. Adisesha
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
Prof. Dr. K. Adisesha
 

More from Prof. Dr. K. Adisesha (20)

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
 
Operating System-1 by Adi.pdf
Operating System-1 by Adi.pdfOperating System-1 by Adi.pdf
Operating System-1 by Adi.pdf
 
Operating System-adi.pdf
Operating System-adi.pdfOperating System-adi.pdf
Operating System-adi.pdf
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdfData_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 

Recently uploaded

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 

Recently uploaded (20)

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 

Sql ppt

  • 1. Structured Query Language Prof. K ADISESHA (Ph. D)
  • 2. Introduction Architecture of SQL SQL Commands SQL Data types Data Warehouse 2Structured Query Language Prof. K. Adisesha
  • 3. Structured Query Language Prof. K. Adisesha (Ph. D) 3 Structured Query Language (SQL): SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving data stored in relational database.  Structured Query Language and it helps to make practice on SQL commands which provides immediate results.  SQL is the standard language for Relation Database System.  All relational database management systems like MySQL, MS Access, and Oracle, Sybase, Informix, and SQL Server use SQL as standard database language.
  • 4. Structured Query Language Prof. K. Adisesha (Ph. D) 4 A Brief History of SQL: A Relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd.  1970 − Dr. Edgar F. "Ted" Codd of IBM is known as the father of relational databases. He described a relational model for databases.  1974 − Structured Query Language appeared.  1978 − IBM worked to develop Codd's ideas and released a product named System/R.  1986 − IBM developed the first prototype of relational database and standardized by ANSI. The first relational database was released by Relational Software which later came to be known as Oracle.
  • 5. Structured Query Language Prof. K. Adisesha (Ph. D) 5 Structured Query Language (SQL): SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving data stored in relational database.
  • 6. Structured Query Language Prof. K. Adisesha (Ph. D) 6 Structured Query Language (SQL): When you are executing an SQL command for any RDBMS, the system determines the best way to carry out your request and SQL engine figures out how to interpret the task.  There are various components included in the process.  These components are:  Query Dispatcher  Optimization Engines  Classic Query Engine  SQL Query Engine
  • 7. Structured Query Language Prof. K. Adisesha (Ph. D) 7 Need for SQL: SQL is Structured Query Language used for storing, manipulating and retrieving data stored in relational database.  Allows users to create and drop databases and tables.  Allows users to describe the data.  Allows users to define the data in database and manipulate that data.  Allows users to access data in relational database management systems.  Allows embedding within other languages using SQL modules, libraries & pre- compilers.  Allows users to set permissions on tables, procedures, and views
  • 8. Structured Query Language Prof. K. Adisesha (Ph. D) 8 SQL Commands: The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT, UPDATE, DELETE and DROP.  These commands can be classified into groups based on their nature:  DDL - Data Definition Language  DML - Data Manipulation Language  DCL - Data Control Language  TCL – Transaction Control Language
  • 9. Structured Query Language Prof. K. Adisesha (Ph. D) 9 Data Definition Language (DDL): DDL defines the conceptual schema providing a link between the logical and the physical structure of the database.  The functions of the Data Definition Language (DDL) are:  It defines the physical characteristics of each record, filed in the record, field’s data type, field's length, field’s logical name and also specify relationship among those records.  Describes the schema and subschema.  Indicates the keys of records.  Provides data security measures.  Provides for the logical and physical data independence.
  • 10. Structured Query Language Prof. K. Adisesha (Ph. D) 10 Data Definition Language (DDL): DDL defines the conceptual schema providing a link between the logical and the physical structure of the database.  Few of the basic commands for DDL are: Command Description CREATE Creates a new table, a view of a table, or other object in the database. ALTER Modifies an existing database object, such as a table DROP Deletes an entire table, a view of a table or other objects in the database. RENAME Renames an existing database object, such as a table
  • 11. Structured Query Language Prof. K. Adisesha (Ph. D) 11 Data Manipulation Language(DML): DML provides the data manipulation techniques like selection, insertion, deletion, updation, modification, replacement, retrieval, sorting and display of data or records.  DML facilitates use of relationship between the records.  DML provides for independence of programming languages by supporting several high-level programming languages like COBOL, PL/1 and C++.:
  • 12. Structured Query Language Prof. K. Adisesha (Ph. D) 12 Data Manipulation Language(DML): DML provides the data manipulation techniques like selection, insertion, deletion, updation, modification, replacement, retrieval, sorting and display of data or records.  Few of the basic commands for DML are: Command Description INSERT Creates a record. UPDATE Modifies records. DELETE Deletes records.
  • 13. Structured Query Language Prof. K. Adisesha (Ph. D) 13 Data Control Language (DCL): These SQL commands are used for providing security to database objects.  Few of the basic commands for DCL are: Command Description GRANT Gives a privilege to user. Such as setting Passwords to Database Users REVOKE Takes back privileges granted from user.
  • 14. Structured Query Language Prof. K. Adisesha (Ph. D) 14 Transaction Control Language (TCL): It includes commands to control the transactions in a database system.  Few of the basic commands for TCL are: Command Description SELECT Retrieves certain records from one or more tables syntax: >SELECT * FROM table_name;
  • 15. Data Types in SQL Prof. K. Adisesha (Ph. D) 15 Data Types in SQL:  The following are the most common data types of SQL Data Data Type From To Numeric int -2,147,483,648 2,147,483,647 numeric -10^38 +1 10^38 -1 float -1.79E + 308 1.79E + 308 real -3.40E + 38 3.40E + 38 String Char Maximum length of 8,000 characters Fixed length non-Unicode characters varchar Maximum of 8,000 characters. Variable-length non-Unicode data
  • 16. Data Types in SQL Prof. K. Adisesha (Ph. D) 16 Data Types in SQL:  The following are the most common data types of SQL Data Data Type From To Date/ Time datetime Jan 1, 1753 Dec 31, 9999 smalldatetime Jan 1, 1900 Jun 6, 2079 date Stores a date like June 30, 2020 time Stores a time of day like 12:30 P.M. timestamp Stores a database-wide unique number that gets updated every time a row gets updated
  • 17. Operator in SQL Prof. K. Adisesha (Ph. D) 17 Operator in SQL: An operator is a reserved word or a character used primarily in an SQL statement's WHERE clause to perform operation(s), such as comparisons and arithmetic operations.  These Operators are used to specify conditions in an SQL statement and to serve as conjunctions for multiple conditions in a statement.  Arithmetic operators  Comparison operators  Logical operators  Operators used to negate conditions
  • 18. Arithmetic Operators Prof. K. Adisesha (Ph. D) 18 Arithmetic Operators in SQL:  The following are the most common Arithmetic Operators of SQL: Given a=10, b=20 Operator Description Example (Addition) + Adds values on either side of the operator a + b will give 30 (Subtraction) - Subtracts right hand operand from left hand operand. a - b will give -10 (Multiplication) * Multiplies values on either side of the operator. a * b will give 200 (Division) / Divides left hand operand by right hand operand. b / a will give 2 (Modulus) % Divides left hand operand by right hand operand and returns remainder. b % a will give 0
  • 19. Operator Description Example = Checks if the values of two operands are equal or not, if yes then condition becomes true. (a = b) is False != , < > Checks if the values of two operands are equal or not, if values are not equal then condition becomes true.. (a != b) is true (a <> b) is true >, >= Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. (a > b) is False (a >= b) is False < , <= Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. (a < b) is true (a <= b) is true ! > , !< Checks if the value of left operand is not less than the value of right operand, if yes then condition becomes true. (a !< b) is false (a !> b) is true Comparison Operators Prof. K. Adisesha (Ph. D) 19 Comparison Operators in SQL:  The following are the most common Comparison Operators of SQL: Given a=10, b=20
  • 20. Logical Operators Prof. K. Adisesha (Ph. D) 20 Logical Operators in SQL:  The following are the most common Logical Operators of SQL: Operator Description ALL, ANY The ALL operator is used to compare a value to all values in another value set. The ANY operator is used to compare a value to any applicable value in the list on condition AND, OR The AND, OR operator allows the existence of multiple conditions in an SQL statement's NOT The NOT operator reverses the meaning of the logical operator with which it is used BETWEEN The BETWEEN operator is used to search for values that are within a set of values, given the minimum value and the maximum value. EXISTS The EXISTS operator is used to search for the presence of a row in a specified table that meets a certain criterion. UNIQUE he UNIQUE operator searches every row of a specified table for uniqueness
  • 21. SQL - Expressions Prof. K. Adisesha (Ph. D) 21 Expressions in SQL: An expression is a combination of one or more values, operators and SQL functions that evaluate to a value..  These SQL EXPRESSIONs are like formulae and they are written in query language.  There are different types of SQL expressions are:  Boolean  Numeric  Date
  • 22. SQL - Expressions Prof. K. Adisesha (Ph. D) 22 Boolean Expressions in SQL: SQL Boolean Expressions fetch the data based on matching a single value.  Following is the syntax: SELECT column1, column2, .. columnN FROM table_name WHERE SINGLE VALUE MATCHING EXPRESSION;  Example showing the usage of various SQL Boolean Expressions − SQL> SELECT * FROM CUSTOMERS WHERE SALARY = 20000;
  • 23. SQL - Expressions Prof. K. Adisesha (Ph. D) 23 Numeric Expression in SQL: These expressions are used to perform any mathematical operation in any query.  The numerical expression is used for a mathematical expression or any formula  Following is the syntax: SELECT numerical expression as OPERATION_NAME [FROM table_name WHERE CONDITION] ;  Example showing the usage of various SQL Numeric Expressions − SQL> SELECT (15 + 6) AS ADDITION; SQL> SELECT COUNT(*) AS "RECORDS" FROM CUSTOMERS;
  • 24. SQL - Expressions Prof. K. Adisesha (Ph. D) 24 Date Expressions in SQL: These expressions are used to calculate and return the Date and Time operation in any query.  Date Expressions return current system date and time values  Following is the syntax: SQL> SELECT CURRENT_TIMESTAMP;  Example showing the usage of various SQL Numeric Expressions − SQL> SELECT GETDATE();
  • 25. SQL - Database Prof. K. Adisesha (Ph. D) 25 Managing Database in SQL: Always the database name should be unique within the RDBMS CREATE Database:  The SQL CREATE DATABASE statement is used to create a new SQL database  Syntax: CREATE DATABASE DatabaseName; DROP or DELETE Database  The SQL DROP DATABASE statement is used to drop an existing database in SQL schema  Syntax: DROP DATABASE DatabaseName; SELECT Database, USE Statement  The SQL USE statement is used to select any existing database in the SQL schema  Syntax: USE DatabaseName;
  • 26. SQL - CREATE Table Prof. K. Adisesha (Ph. D) 26 SQL CREATE TABLE Statement: Creating a basic table involves naming the table and defining its columns and each column's data type.  The SQL CREATE TABLE statement is used to create a new table  Syntax: Example:
  • 27. SQL - Drop Table Prof. K. Adisesha (Ph. D) 27 SQL Drop TABLE Statement: The SQL DROP TABLE statement is used to remove a table definition and all the data, indexes, triggers, constraints and permission specifications for that table..  The DROP TABLE statement is used to drop an existing table in a database  Deleting a table will result in loss of complete information stored in the table!  Syntax: Example: SQL TRUNCATE TABLE  The TRUNCATE TABLE statement is used to delete the data inside a table, but not the table itself.  Syntax:
  • 28. SQL - Alter Table Prof. K. Adisesha (Ph. D) 28 SQL Alter TABLE Statement: The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. ALTER TABLE - ADD Column  To add a column in a table, use the following syntax: ALTER TABLE - DROP Column  To drop a column in a table, use the following syntax: ALTER TABLE - ALTER/MODIFY Column  To drop a column in a table, use the following syntax:
  • 29. SQL Constraints Prof. K. Adisesha (Ph. D) 29 SQL Create Constraints: Constraints can be specified when the table is created with the CREATE TABLE statement, or after the table is created with the ALTER TABLE statement.  SQL constraints are used to specify rules for the data in a table  The following constraints are commonly used in SQL:  NOT NULL - Ensures that a column cannot have a NULL value  UNIQUE - Ensures that all values in a column are different  PRIMARY KEY - A combination of a NOT NULL and UNIQUE.  FOREIGN KEY - Uniquely identifies a row/record in another table  CHECK - Ensures that all values in a column satisfies a specific condition  DEFAULT - Sets a default value for a column when no value is specified
  • 30. SQL Constraints Prof. K. Adisesha (Ph. D) 30 SQL Create Constraints: Constraints can be specified when the table is created with the CREATE TABLE statement, or after the table is created with the ALTER TABLE statement.  SQL constraints are used to specify rules for the data in a table  Constraints can be column level or table level.  Syntax: Example:
  • 31. SQL INSERT Statement Prof. K. Adisesha (Ph. D) 31 SQL INSERT INTO Statement: The INSERT INTO statement is used to insert new records in a table.  It is possible to write the INSERT INTO statement in two ways.  The first way specifies both the column names and the values to be inserted  Syntax:  If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query.  Syntax:
  • 32. SQL SELECT Statement Prof. K. Adisesha (Ph. D) 32 SQL SELECT Statement: The SELECT statement is used to select data from a database.  The data returned is stored in a result table, called the result-set.  If you want to select all the fields available in the table, use the following syntax:  The SELECT DISTINCT statement is used to return only distinct (different) values..  Syntax:  The WHERE clause is used to extract only those records that fulfill a specified condition.  Syntax:
  • 33. SQL Joins Prof. K. Adisesha (Ph. D) 33 SQL JOIN: A JOIN clause is used to combine rows from two or more tables, based on a related column between them.  Different types of the JOINs in SQL:  (INNER) JOIN: Returns records that have matching values in both tables  LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table  RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table  FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
  • 34. SQL Joins Prof. K. Adisesha (Ph. D) 34 SQL INNER JOIN: The INNER JOIN keyword selects records that have matching values in both tables.  (INNER) JOIN: Returns records that have matching values in both tables
  • 35. SQL Joins Prof. K. Adisesha (Ph. D) 35 SQL LEFT (OUTER) JOIN: The LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2).  The result is NULL from the right side, if there is no match.  LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
  • 36. SQL Joins Prof. K. Adisesha (Ph. D) 36 SQL RIGHT JOIN: The RIGHT JOIN keyword returns all records from the right table (table2), and the matched records from the left table (table1).  The result is NULL from the left side, when there is no match.  RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
  • 37. SQL Joins Prof. K. Adisesha (Ph. D) 37 SQL FULL OUTER JOIN: The FULL OUTER JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records.  FULL OUTER JOIN can potentially return very large result-sets.  FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
  • 38. SQL ORDER BY Prof. K. Adisesha (Ph. D) 38 SQL ORDER BY Keyword: The ORDER BY keyword is used to sort the result-set in ascending or descending order.  The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.
  • 39. SQL GROUP BY Prof. K. Adisesha (Ph. D) 39 SQL GROUP BY: he GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country".  The GROUP BY statement is often used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns.
  • 40. SQL Functions Prof. K. Adisesha (Ph. D) 40 SQL MIN() and MAX() Functions: The MIN() function returns the smallest value of the selected column.  MIN() Syntax: The MAX() function returns the largest value of the selected column.  MAX() Syntax:
  • 41. SQL Functions Prof. K. Adisesha (Ph. D) 41 SQL COUNT(), AVG() and SUM() Functions:  The COUNT() function returns the number of rows that matches a specified criterion.  The AVG() function returns the average value of a numeric column.  The SUM() function returns the total sum of a numeric column.
  • 42. Discussion Prof. K. Adisesha (Ph. D) 42 Queries ? Prof. K. Adisesha