SlideShare a Scribd company logo
1 of 24
Download to read offline
1
By: Rohan Byanjankar
Sainik Awasiya Mahavidyalaya, Sallaghari, Bhaktapur
CONCEPT
ON
STRUCTURED QUERY LANGUAGE
(SQL)
2
 Structured Query Language (SQL) is the special purposed
programming language,
 Main purpose of SQL to access data in Relational Database
Management System,
 RDBMS is the most revered DBMS, and basis for SQL,
 The data in RDBMS are recorded in relations or table,
 Relation is the pre-defined rows and column, where column contains
attributes, and tuples in rows,
 Oracle, SQL Server, MySQL are the examples…
Structured Query Language
3
Major Two Languages in RDBMS
Data Definition
Language
Data Manipulation
Language
4
• One of the fundamental requirements of SQL,
• One is dumb in the SQL without knowledge of DDL,
• Backbone of SQL,
• Helps to develop overall design of database,
• Helps to create, delete, and modify the database schema,
• Not frequently used as database schema is not frequently
changed,
Data Definition Language (DDL)
5
• Create
• Use
• Drop
• Alter
Basic DDL Commands
6
One of the fundamental commands,
Use to establish many new independent database in DBMS,
Use to create table within newly established database or existing
database,
Syntax:
- CREATE DATABASE SAMB
- CREATE TABLE Students
Create Command
7
One of the fundamental commands,
Helps to work on the newly established or created database,
Syntax:
- USE SAMB
Use Command
One of the DDL commands,
Used to delete column of a table, entire table, and entire database,
We must use drop command with intense care,
Syntax:
- DROP TABLE Student
- DROP DATABASE SAMB
Drop Command
8
• Falls under the category of DDL command,
• Used to change the structure of table without deleting or re-creating
the table,
• Syntax:
1. ALTER TABLE Student
ADD Email_id VARCHAR(20)
2. ALTER TABLE Student
DROP COLUMN Email_id
Alter Command
9
• One of the fundamental requirements of SQL,
• DML helps to work on RDBMS,
• Helps to change the content of RDBMS,
• Helps to insert, select, update and delete the database
instances,
• Frequently used as frequent modification is made in database,
Data Manipulation Language (DML)
10
• Insert
• Select
• Update
• Delete
Basic DML Command
11
• Basic DML command,
• Used to add new data in database,
• The most frequently used,
Syntax:
• INERT INTO Student VALUES (0020, ‘Sujita Shrestha’, ‘BBA’,
16, ‘sujita98@gmail.com’)
• INSERT INTO Student (sid, sname, grade) VALUES (0023,
‘Smiriti KC’, ‘BBA’)
Insert Command
12
• Enables to select data from database,
• Syntax:
• To select all
• SELECT * FROM Student
• To select students with name staring from ‘S’
• SELECT * FROM Student where sname=‘s%’
• To select students according to ID in descending order
• SELECT * FROM Student
ORDER BY sid desc
Select Command
13
• Used to update existing record in a table,
• Syntax:
• UPDATE table_name SET column1= Value1
• For Example:
• To update salary to 1.5 times of existing salary of an employee
with empid 19
• UPDATE tblemployee SET salary = 1.5*salary
Update Command
WHERE empid= 19
14
• Enables us to remove the selected tuple or entire tuple without
making alter to the table,
• Syntax:
• DELETE FROM table_name WHERE column1= ‘Value1’
• For Example:
• If Student with sid 0001 is needed to be removed from Student
table, then
• DELETE FROM Student
Delete Command
WHERE sid= 0001
15
• SQL View is a logical table,
• Created from the existing table,
• Virtual table based on real table,
• Constraints of Base table is applicable in View also.
• Any modification in base table is reflected in View.
• User can Use DML commands once the view is created.
SQL Views
16
CREATE VIEW View_name AS
SELECT column1, column2, column3 FROM
Table_1 WHERE column3= ‘Value1’
For Example:
To create view from table Product (Pid, Pname, Cost Price, Selling
Price, Manu_date, Exp_date, Category) to Beverage Department
CREATE VIEW Beverage AS
SELECT Pid, Pname, Selling Price, Manu_date, Exp_date
FROM Product WHERE Category= ‘Beverage’
Syntax
17
Pid Pname Cost Price Selling Price Manu_date Exp_date Category
001 Parle-G 88 95 2014-01-05 2014-07-05 General
002 Coca-Cola 130 149 2013-12-09 2014-06-09 Beverage
003 Toberg 200 220 2013-11-14 2014-07-11 Beverage
004 Sunflow Oil 300 350 2013-08-08 2014-08-08 General
Pid Pname Selling Price Manu_date Exp_date
002 Coca-Cola 149 2013-12-09 2014-06-09
003 Toberg 220 2013-11-14 2014-07-11
Product
Beverage
CREATE VIEW Beverage AS
SELECT Pid, Pname, Selling Price, Manu_date, Exp_date
FROM Product WHERE Category= ‘Beverage’
Beverage
Department
18
• A database index is a data structure that improves the speed of
data retrieval operations on a database table,
• used to quickly locate data without having to search every row
Syntax:
CREATE INDEX index_name ON
Table_name (column1)
Index
19
For Example: To create INDEX on table Library (ISBN,
Bname, Price, Author)
CREATE INDEX Book_index ON
Library (ISBN)
Contd…
ISBN Bname Price Author
000-124-456 The Old Man and The Sea Rs. 97 Ernest Hemingway
978-1-85326-067-4 Far from the Madding Crowd Rs. 200 Thomas Hardy
978-81-291-0818-0 One Night @ The Call Center Rs. 200 Chetan Bhagat
Library
20
• Those functions that perform a calculation on a set of values and
return a single value.
• MAX, MIN, AVG, COUNT are the examples…
Syntax:
1. SELECT Column1, MAX(Column2) AS MAX_Price FROM
Tbleproduct
2. SELECT Column1, MIN(Column2) AS MIN_Price FROM
Tbleproduct
3. SELECT Column1, AVG(Column2) AS AVG_Price FROM
Tbleproduct
Aggregate Function
21
SELECT Category, MAX(Selling_Price) AS MAX_SP FROM Product
GROUP BY Category
Contd…
Pid Pname Cost_Price Selling_Price Manu_date Exp_date Category
001 Parle-G 88 95 2014-01-05 2014-07-05 General
002 Coca-Cola 130 149 2013-12-09 2014-06-09 Beverage
003 Tuborg 200 220 2013-11-14 2014-07-11 Beverage
004 Sunflow Oil 300 350 2013-08-08 2014-08-08 General
Product
Category MAX_SP
Beverage 220
General 350
22
• SQL join is the operation that enables us to get the combined
Values of attributes of two tables,
• The most common type of join is ‘Inner Join’.
Syntax:
SELECT column1, column2, column3, column5, column6 FROM
Table1
INNER JOIN Table2 ON
Table1.Column1=Table2.column5
Note:
Data type of column1 and column5 must be identical
Joins
23
ISBN Bname Price Author
000-124-456 The Old Man and The Sea Rs. 97 Ernest Hemingway
978-1-85326-067-4 Far from the Madding Crowd Rs. 200 Thomas Hardy
978-81-291-0818-0 One Night @ The Call Center Rs. 200 Chetan Bhagat
ID Sname Grade ISBN1
0001 Sanjay Sharma BBA 978-81-291-0818-0
0002 Sushil Shrestha BSC 000-124-456
0030 Samikshaya Sharma BBA 978-1-85326-067-4
Library
Student
SELECT ISBN, Bname, ID, Sname, Grade, ISBN1 FROM Library
INNER JOIN Student ON
Library.ISBN= Student.ISBN1
ISBN Bname ID Sname Grade
978-81-291-0818-0 One Night @ The Call Center 0001 Sanjay Sharma BBA
000-124-456 The Old Man and The Sea 0002 Sushil Shrestha BSC
978-1-85326-067-4 Far from the Madding Crowd 0030 Samikshaya Sharma BBA
24
Create Table Student with
following attributes:
SQL Question:
ID Number Primary Key
Name Text Not Null and
length<40
Age Number >17 and <25
Grade Text BBA or BSC
Not Null
Email Text Unique
Not Null
Contact Text Not Null
Length= 7 or 10
Address Text Not Null
CREATE TABLE Student (
ID INT,
Sname VARCHAR (50) NOT NULL,
Age INT,
Grade VARCHAR (8) NOT NULL,
Email_id VARCHAR (30) UNIQUE NOT NULL,
Contact VARCHAR (13) NOT NULL,
Address VARCHAR (30) NOT NULL,
CONSTRAINT pk_id PRIMARY KEY (ID),
CONSTRAINT ch_values CHECK
(LEN(Sname)<40),
CONSTRAINT ch_values1 CHECK(Grade IN
(‘BBA’,’BSC’)),
CONSTRAINT ch_values2 CHECK
(LEN(Contact)=7 OR LEN(Contact)=10));

More Related Content

What's hot

Database Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity TypesDatabase Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity Typesaakanksha s
 
Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overviewhonglee71
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentationNITISH KUMAR
 
Advanced SQL
Advanced SQLAdvanced SQL
Advanced SQLSabiha M
 
5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdf5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdfSunita Milind Dol
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)Syed Hassan Ali
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer joinNargis Ehsan
 
DataFrame in Python Pandas
DataFrame in Python PandasDataFrame in Python Pandas
DataFrame in Python PandasSangita Panchal
 
Introduction to ETL process
Introduction to ETL process Introduction to ETL process
Introduction to ETL process Omid Vahdaty
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functionsfarwa waqar
 

What's hot (20)

DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Database Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity TypesDatabase Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity Types
 
Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
 
Sql - Structured Query Language
Sql - Structured Query LanguageSql - Structured Query Language
Sql - Structured Query Language
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
 
Advanced SQL
Advanced SQLAdvanced SQL
Advanced SQL
 
5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdf5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdf
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
Sql commands
Sql commandsSql commands
Sql commands
 
Chapter 17 Tuples
Chapter 17 TuplesChapter 17 Tuples
Chapter 17 Tuples
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
 
Database and types of database
Database and types of databaseDatabase and types of database
Database and types of database
 
DataFrame in Python Pandas
DataFrame in Python PandasDataFrame in Python Pandas
DataFrame in Python Pandas
 
Introduction to ETL process
Introduction to ETL process Introduction to ETL process
Introduction to ETL process
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
List in Python
List in PythonList in Python
List in Python
 
Plsql lab mannual
Plsql lab mannualPlsql lab mannual
Plsql lab mannual
 

Viewers also liked

Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)Hammad Rasheed
 
Análisis y perspectivas del cluster canalero
Análisis y perspectivas del cluster canaleroAnálisis y perspectivas del cluster canalero
Análisis y perspectivas del cluster canaleroCésar Valdés P.
 
Farmacocinética
FarmacocinéticaFarmacocinética
Farmacocinéticaoreci
 
OPIM FINAL TURN IN
OPIM FINAL TURN INOPIM FINAL TURN IN
OPIM FINAL TURN INBrooke Rice
 
HFH Who We Are_Hi-Res
HFH Who We Are_Hi-ResHFH Who We Are_Hi-Res
HFH Who We Are_Hi-ResJames Allport
 
taller #1 power point-apudep4
taller #1 power point-apudep4taller #1 power point-apudep4
taller #1 power point-apudep4César Valdés P.
 
My vacations erika mayerly
My vacations erika mayerly My vacations erika mayerly
My vacations erika mayerly solkaflam
 
LinkedIn Profile template
LinkedIn Profile templateLinkedIn Profile template
LinkedIn Profile templateKevin Dixon
 
Consumer Behavior Project
Consumer Behavior ProjectConsumer Behavior Project
Consumer Behavior ProjectLauren Kucic
 
Consumer Behavior Lab
Consumer Behavior LabConsumer Behavior Lab
Consumer Behavior LabLauren Kucic
 
How to sharpen skis
How to sharpen skisHow to sharpen skis
How to sharpen skisfoleycs
 
PROYECTO DE VIDA INVESTIGACIÓN CIENCIA Y TECNOLOGIA
PROYECTO DE VIDA INVESTIGACIÓN CIENCIA Y TECNOLOGIAPROYECTO DE VIDA INVESTIGACIÓN CIENCIA Y TECNOLOGIA
PROYECTO DE VIDA INVESTIGACIÓN CIENCIA Y TECNOLOGIAmiltonloor
 

Viewers also liked (19)

Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
Análisis y perspectivas del cluster canalero
Análisis y perspectivas del cluster canaleroAnálisis y perspectivas del cluster canalero
Análisis y perspectivas del cluster canalero
 
Farmacocinética
FarmacocinéticaFarmacocinética
Farmacocinética
 
OPIM FINAL TURN IN
OPIM FINAL TURN INOPIM FINAL TURN IN
OPIM FINAL TURN IN
 
Whitmore Sonja 3.3
Whitmore Sonja 3.3Whitmore Sonja 3.3
Whitmore Sonja 3.3
 
HFH Who We Are_Hi-Res
HFH Who We Are_Hi-ResHFH Who We Are_Hi-Res
HFH Who We Are_Hi-Res
 
taller #1 power point-apudep4
taller #1 power point-apudep4taller #1 power point-apudep4
taller #1 power point-apudep4
 
My vacations erika mayerly
My vacations erika mayerly My vacations erika mayerly
My vacations erika mayerly
 
LinkedIn Profile template
LinkedIn Profile templateLinkedIn Profile template
LinkedIn Profile template
 
700 dinámicas
700 dinámicas700 dinámicas
700 dinámicas
 
mena george
mena george mena george
mena george
 
Consumer Behavior Project
Consumer Behavior ProjectConsumer Behavior Project
Consumer Behavior Project
 
Rosie BDCH artwork
Rosie BDCH artworkRosie BDCH artwork
Rosie BDCH artwork
 
sidewinders
sidewinderssidewinders
sidewinders
 
DOS Chip Moreland M28 EE
DOS Chip Moreland M28 EEDOS Chip Moreland M28 EE
DOS Chip Moreland M28 EE
 
KEI_Book_Sample
KEI_Book_SampleKEI_Book_Sample
KEI_Book_Sample
 
Consumer Behavior Lab
Consumer Behavior LabConsumer Behavior Lab
Consumer Behavior Lab
 
How to sharpen skis
How to sharpen skisHow to sharpen skis
How to sharpen skis
 
PROYECTO DE VIDA INVESTIGACIÓN CIENCIA Y TECNOLOGIA
PROYECTO DE VIDA INVESTIGACIÓN CIENCIA Y TECNOLOGIAPROYECTO DE VIDA INVESTIGACIÓN CIENCIA Y TECNOLOGIA
PROYECTO DE VIDA INVESTIGACIÓN CIENCIA Y TECNOLOGIA
 

Similar to Concept of Structured Query Language (SQL) in SQL server as well as MySql. BBA 2nd Semester, Tribhuvan University.

SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxKashifManzoorMeo
 
Structured Query Language introduction..
Structured Query Language introduction..Structured Query Language introduction..
Structured Query Language introduction..FerryKemperman
 
MySQL 5.7: Core Server Changes
MySQL 5.7: Core Server ChangesMySQL 5.7: Core Server Changes
MySQL 5.7: Core Server ChangesMorgan Tocker
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxQuyVo27
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxBhupendraShahi6
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1Dan D'Urso
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Antonios Chatzipavlis
 
Public Training SQL Implementation & Embedded Programming in IBM i (05-09 Jun...
Public Training SQL Implementation & Embedded Programming in IBM i (05-09 Jun...Public Training SQL Implementation & Embedded Programming in IBM i (05-09 Jun...
Public Training SQL Implementation & Embedded Programming in IBM i (05-09 Jun...Hany Paulina
 
Public Training SQL Implementation & Embedded Programming in IBM i
Public Training SQL Implementation & Embedded Programming in IBM iPublic Training SQL Implementation & Embedded Programming in IBM i
Public Training SQL Implementation & Embedded Programming in IBM iHany Paulina
 
Structured Query Language (SQL).pptx
Structured Query Language (SQL).pptxStructured Query Language (SQL).pptx
Structured Query Language (SQL).pptxEllenGracePorras
 
Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2Koen Van Hulle
 
SQL Fundamentals - Lecture 2
SQL Fundamentals - Lecture 2SQL Fundamentals - Lecture 2
SQL Fundamentals - Lecture 2MuhammadWaheed44
 

Similar to Concept of Structured Query Language (SQL) in SQL server as well as MySql. BBA 2nd Semester, Tribhuvan University. (20)

SQL NAD DB.pptx
SQL NAD DB.pptxSQL NAD DB.pptx
SQL NAD DB.pptx
 
SQL(database)
SQL(database)SQL(database)
SQL(database)
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
 
SQL_NOTES.pdf
SQL_NOTES.pdfSQL_NOTES.pdf
SQL_NOTES.pdf
 
Structured Query Language introduction..
Structured Query Language introduction..Structured Query Language introduction..
Structured Query Language introduction..
 
MySQL 5.7: Core Server Changes
MySQL 5.7: Core Server ChangesMySQL 5.7: Core Server Changes
MySQL 5.7: Core Server Changes
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
 
chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019
 
Public Training SQL Implementation & Embedded Programming in IBM i (05-09 Jun...
Public Training SQL Implementation & Embedded Programming in IBM i (05-09 Jun...Public Training SQL Implementation & Embedded Programming in IBM i (05-09 Jun...
Public Training SQL Implementation & Embedded Programming in IBM i (05-09 Jun...
 
Public Training SQL Implementation & Embedded Programming in IBM i
Public Training SQL Implementation & Embedded Programming in IBM iPublic Training SQL Implementation & Embedded Programming in IBM i
Public Training SQL Implementation & Embedded Programming in IBM i
 
Structured Query Language (SQL).pptx
Structured Query Language (SQL).pptxStructured Query Language (SQL).pptx
Structured Query Language (SQL).pptx
 
Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2
 
Oracle Material.pdf
Oracle Material.pdfOracle Material.pdf
Oracle Material.pdf
 
SQL Fundamentals - Lecture 2
SQL Fundamentals - Lecture 2SQL Fundamentals - Lecture 2
SQL Fundamentals - Lecture 2
 

More from Rohan Byanjankar

12 Reasons for Never, Ever carrying out Data Analysis
12 Reasons for Never, Ever carrying out Data Analysis12 Reasons for Never, Ever carrying out Data Analysis
12 Reasons for Never, Ever carrying out Data AnalysisRohan Byanjankar
 
Risk Associated with Derivative Markets
Risk Associated with Derivative MarketsRisk Associated with Derivative Markets
Risk Associated with Derivative MarketsRohan Byanjankar
 
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...Rohan Byanjankar
 
Multiplier: Concept, Types, and Derivation of each type of Multiplier
Multiplier: Concept, Types, and Derivation of each type of MultiplierMultiplier: Concept, Types, and Derivation of each type of Multiplier
Multiplier: Concept, Types, and Derivation of each type of MultiplierRohan Byanjankar
 
Origin of Nepal: Nepal as a Sovereign Country
Origin of Nepal: Nepal as a Sovereign CountryOrigin of Nepal: Nepal as a Sovereign Country
Origin of Nepal: Nepal as a Sovereign CountryRohan Byanjankar
 
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...Rohan Byanjankar
 
Human Development Index; Components of Human Development Index, Significance ...
Human Development Index; Components of Human Development Index, Significance ...Human Development Index; Components of Human Development Index, Significance ...
Human Development Index; Components of Human Development Index, Significance ...Rohan Byanjankar
 
A Study on Online Health Service at HamroDoctor
A Study on Online Health Service at HamroDoctorA Study on Online Health Service at HamroDoctor
A Study on Online Health Service at HamroDoctorRohan Byanjankar
 
Siddhi Memorial Foundation, Bhaktapur, Nepal
Siddhi Memorial Foundation, Bhaktapur, NepalSiddhi Memorial Foundation, Bhaktapur, Nepal
Siddhi Memorial Foundation, Bhaktapur, NepalRohan Byanjankar
 
Trade and Export Promotion Centre, Nepal
Trade and Export Promotion Centre, NepalTrade and Export Promotion Centre, Nepal
Trade and Export Promotion Centre, NepalRohan Byanjankar
 
Sociology and Religion: Religion as a Social Institution
Sociology and Religion: Religion as a Social InstitutionSociology and Religion: Religion as a Social Institution
Sociology and Religion: Religion as a Social InstitutionRohan Byanjankar
 
Inductive and Deductive Approach to Research. Difference between Inductive an...
Inductive and Deductive Approach to Research. Difference between Inductive an...Inductive and Deductive Approach to Research. Difference between Inductive an...
Inductive and Deductive Approach to Research. Difference between Inductive an...Rohan Byanjankar
 
Online Business; What is E-commerce; What are the points to be considered whi...
Online Business; What is E-commerce; What are the points to be considered whi...Online Business; What is E-commerce; What are the points to be considered whi...
Online Business; What is E-commerce; What are the points to be considered whi...Rohan Byanjankar
 
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...Rohan Byanjankar
 
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...Rohan Byanjankar
 
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...Rohan Byanjankar
 
Difference between selling concept and marketing concept
Difference between selling concept and marketing conceptDifference between selling concept and marketing concept
Difference between selling concept and marketing conceptRohan Byanjankar
 

More from Rohan Byanjankar (19)

12 Reasons for Never, Ever carrying out Data Analysis
12 Reasons for Never, Ever carrying out Data Analysis12 Reasons for Never, Ever carrying out Data Analysis
12 Reasons for Never, Ever carrying out Data Analysis
 
Concept of annuity
Concept of annuityConcept of annuity
Concept of annuity
 
Risk Associated with Derivative Markets
Risk Associated with Derivative MarketsRisk Associated with Derivative Markets
Risk Associated with Derivative Markets
 
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...
Relationship between Average Revenue (AR), Marginal Revenue (MR), and Elastic...
 
Multiplier: Concept, Types, and Derivation of each type of Multiplier
Multiplier: Concept, Types, and Derivation of each type of MultiplierMultiplier: Concept, Types, and Derivation of each type of Multiplier
Multiplier: Concept, Types, and Derivation of each type of Multiplier
 
Origin of Nepal: Nepal as a Sovereign Country
Origin of Nepal: Nepal as a Sovereign CountryOrigin of Nepal: Nepal as a Sovereign Country
Origin of Nepal: Nepal as a Sovereign Country
 
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...
Understanding Interest Rate Swap: Price of Interest Rate Swap and Value of In...
 
Human Development Index; Components of Human Development Index, Significance ...
Human Development Index; Components of Human Development Index, Significance ...Human Development Index; Components of Human Development Index, Significance ...
Human Development Index; Components of Human Development Index, Significance ...
 
A Study on Online Health Service at HamroDoctor
A Study on Online Health Service at HamroDoctorA Study on Online Health Service at HamroDoctor
A Study on Online Health Service at HamroDoctor
 
Siddhi Memorial Foundation, Bhaktapur, Nepal
Siddhi Memorial Foundation, Bhaktapur, NepalSiddhi Memorial Foundation, Bhaktapur, Nepal
Siddhi Memorial Foundation, Bhaktapur, Nepal
 
Trade and Export Promotion Centre, Nepal
Trade and Export Promotion Centre, NepalTrade and Export Promotion Centre, Nepal
Trade and Export Promotion Centre, Nepal
 
Introduction to HASERA
Introduction to HASERAIntroduction to HASERA
Introduction to HASERA
 
Sociology and Religion: Religion as a Social Institution
Sociology and Religion: Religion as a Social InstitutionSociology and Religion: Religion as a Social Institution
Sociology and Religion: Religion as a Social Institution
 
Inductive and Deductive Approach to Research. Difference between Inductive an...
Inductive and Deductive Approach to Research. Difference between Inductive an...Inductive and Deductive Approach to Research. Difference between Inductive an...
Inductive and Deductive Approach to Research. Difference between Inductive an...
 
Online Business; What is E-commerce; What are the points to be considered whi...
Online Business; What is E-commerce; What are the points to be considered whi...Online Business; What is E-commerce; What are the points to be considered whi...
Online Business; What is E-commerce; What are the points to be considered whi...
 
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...
NEPAL; Demographic Analysis of Nepal; Comparative Study of Various Census and...
 
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
 
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...
Microeconomics: Concept of Indifference Curve and Budget Line. Definition of ...
 
Difference between selling concept and marketing concept
Difference between selling concept and marketing conceptDifference between selling concept and marketing concept
Difference between selling concept and marketing concept
 

Recently uploaded

Automation in the Odoo 17 ERP Studio Module
Automation in the Odoo 17 ERP Studio ModuleAutomation in the Odoo 17 ERP Studio Module
Automation in the Odoo 17 ERP Studio ModuleCeline George
 
18. Training and prunning of horicultural crops.pptx
18. Training and prunning of horicultural crops.pptx18. Training and prunning of horicultural crops.pptx
18. Training and prunning of horicultural crops.pptxUmeshTimilsina1
 
4.4.24 Economic Precarity and Global Economic Forces.pptx
4.4.24 Economic Precarity and Global Economic Forces.pptx4.4.24 Economic Precarity and Global Economic Forces.pptx
4.4.24 Economic Precarity and Global Economic Forces.pptxmary850239
 
Bohemian Grove Full Member List LEAK.pdf
Bohemian Grove Full Member List LEAK.pdfBohemian Grove Full Member List LEAK.pdf
Bohemian Grove Full Member List LEAK.pdfvirusmortal81
 
LEVERAGING SYNERGISM INDUSTRY-ACADEMIA PARTNERSHIP FOR IMPLEMENTATION OF NAT...
LEVERAGING SYNERGISM INDUSTRY-ACADEMIA PARTNERSHIP FOR IMPLEMENTATION OF  NAT...LEVERAGING SYNERGISM INDUSTRY-ACADEMIA PARTNERSHIP FOR IMPLEMENTATION OF  NAT...
LEVERAGING SYNERGISM INDUSTRY-ACADEMIA PARTNERSHIP FOR IMPLEMENTATION OF NAT...pragatimahajan3
 
How to Share Dashboard in the Odoo 17 ERP
How to Share Dashboard in the Odoo 17 ERPHow to Share Dashboard in the Odoo 17 ERP
How to Share Dashboard in the Odoo 17 ERPCeline George
 
Farrington HS Streamlines Guest Entrance
Farrington HS Streamlines Guest EntranceFarrington HS Streamlines Guest Entrance
Farrington HS Streamlines Guest Entrancejulius27264
 
Oxidative phosphorylation and energy calculation of aerobic respiration
Oxidative phosphorylation and energy calculation of aerobic respirationOxidative phosphorylation and energy calculation of aerobic respiration
Oxidative phosphorylation and energy calculation of aerobic respirationTRIDIP BORUAH
 
Calendar, Budget, Evaluation of a PR Campaign
Calendar, Budget, Evaluation of a PR CampaignCalendar, Budget, Evaluation of a PR Campaign
Calendar, Budget, Evaluation of a PR CampaignCorinne Weisgerber
 
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 10 CẢ NĂM (CÓ FILE NGHE) - GLOBAL SUCC...
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 10 CẢ NĂM (CÓ FILE NGHE) - GLOBAL SUCC...BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 10 CẢ NĂM (CÓ FILE NGHE) - GLOBAL SUCC...
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 10 CẢ NĂM (CÓ FILE NGHE) - GLOBAL SUCC...Nguyen Thanh Tu Collection
 
STRAND 5 SST 7 ,,FOR GRADE 7 POLITICAL D
STRAND 5 SST  7 ,,FOR GRADE 7 POLITICAL DSTRAND 5 SST  7 ,,FOR GRADE 7 POLITICAL D
STRAND 5 SST 7 ,,FOR GRADE 7 POLITICAL Dkimdan468
 
Unit IV Knowledge and Hybrid Recommendation System.pdf
Unit IV Knowledge and Hybrid Recommendation System.pdfUnit IV Knowledge and Hybrid Recommendation System.pdf
Unit IV Knowledge and Hybrid Recommendation System.pdfArthyR3
 
How to Override Delete Function in Odoo 17
How to Override Delete Function in Odoo 17How to Override Delete Function in Odoo 17
How to Override Delete Function in Odoo 17Celine George
 
Q4 PPT-Health 9_Lesson 1 (Intentional Injuries).pptx
Q4 PPT-Health 9_Lesson 1 (Intentional Injuries).pptxQ4 PPT-Health 9_Lesson 1 (Intentional Injuries).pptx
Q4 PPT-Health 9_Lesson 1 (Intentional Injuries).pptxSherwinTamayao2
 
AI in the project profession: examples of current use and roadmaps to adoptio...
AI in the project profession: examples of current use and roadmaps to adoptio...AI in the project profession: examples of current use and roadmaps to adoptio...
AI in the project profession: examples of current use and roadmaps to adoptio...Association for Project Management
 
Air permeability control technique in paper making.docx
Air permeability control technique in paper making.docxAir permeability control technique in paper making.docx
Air permeability control technique in paper making.docxNoman khan
 
4.2.24 The Black Panther Party for Self-Defense.pptx
4.2.24 The Black Panther Party for Self-Defense.pptx4.2.24 The Black Panther Party for Self-Defense.pptx
4.2.24 The Black Panther Party for Self-Defense.pptxmary850239
 
(Part 1) CHILDREN'S DISABILITIES AND EXCEPTIONALITIES.pdf
(Part 1) CHILDREN'S DISABILITIES AND EXCEPTIONALITIES.pdf(Part 1) CHILDREN'S DISABILITIES AND EXCEPTIONALITIES.pdf
(Part 1) CHILDREN'S DISABILITIES AND EXCEPTIONALITIES.pdfMJDuyan
 
Air Quality Presentation - EEH Chapter 10
Air Quality Presentation - EEH Chapter 10Air Quality Presentation - EEH Chapter 10
Air Quality Presentation - EEH Chapter 10misteraugie
 

Recently uploaded (20)

Automation in the Odoo 17 ERP Studio Module
Automation in the Odoo 17 ERP Studio ModuleAutomation in the Odoo 17 ERP Studio Module
Automation in the Odoo 17 ERP Studio Module
 
18. Training and prunning of horicultural crops.pptx
18. Training and prunning of horicultural crops.pptx18. Training and prunning of horicultural crops.pptx
18. Training and prunning of horicultural crops.pptx
 
4.4.24 Economic Precarity and Global Economic Forces.pptx
4.4.24 Economic Precarity and Global Economic Forces.pptx4.4.24 Economic Precarity and Global Economic Forces.pptx
4.4.24 Economic Precarity and Global Economic Forces.pptx
 
Bohemian Grove Full Member List LEAK.pdf
Bohemian Grove Full Member List LEAK.pdfBohemian Grove Full Member List LEAK.pdf
Bohemian Grove Full Member List LEAK.pdf
 
LEVERAGING SYNERGISM INDUSTRY-ACADEMIA PARTNERSHIP FOR IMPLEMENTATION OF NAT...
LEVERAGING SYNERGISM INDUSTRY-ACADEMIA PARTNERSHIP FOR IMPLEMENTATION OF  NAT...LEVERAGING SYNERGISM INDUSTRY-ACADEMIA PARTNERSHIP FOR IMPLEMENTATION OF  NAT...
LEVERAGING SYNERGISM INDUSTRY-ACADEMIA PARTNERSHIP FOR IMPLEMENTATION OF NAT...
 
How to Share Dashboard in the Odoo 17 ERP
How to Share Dashboard in the Odoo 17 ERPHow to Share Dashboard in the Odoo 17 ERP
How to Share Dashboard in the Odoo 17 ERP
 
Farrington HS Streamlines Guest Entrance
Farrington HS Streamlines Guest EntranceFarrington HS Streamlines Guest Entrance
Farrington HS Streamlines Guest Entrance
 
Oxidative phosphorylation and energy calculation of aerobic respiration
Oxidative phosphorylation and energy calculation of aerobic respirationOxidative phosphorylation and energy calculation of aerobic respiration
Oxidative phosphorylation and energy calculation of aerobic respiration
 
CARNAVAL COM MAGIA E EUFORIA _
CARNAVAL COM MAGIA E EUFORIA            _CARNAVAL COM MAGIA E EUFORIA            _
CARNAVAL COM MAGIA E EUFORIA _
 
Calendar, Budget, Evaluation of a PR Campaign
Calendar, Budget, Evaluation of a PR CampaignCalendar, Budget, Evaluation of a PR Campaign
Calendar, Budget, Evaluation of a PR Campaign
 
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 10 CẢ NĂM (CÓ FILE NGHE) - GLOBAL SUCC...
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 10 CẢ NĂM (CÓ FILE NGHE) - GLOBAL SUCC...BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 10 CẢ NĂM (CÓ FILE NGHE) - GLOBAL SUCC...
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 10 CẢ NĂM (CÓ FILE NGHE) - GLOBAL SUCC...
 
STRAND 5 SST 7 ,,FOR GRADE 7 POLITICAL D
STRAND 5 SST  7 ,,FOR GRADE 7 POLITICAL DSTRAND 5 SST  7 ,,FOR GRADE 7 POLITICAL D
STRAND 5 SST 7 ,,FOR GRADE 7 POLITICAL D
 
Unit IV Knowledge and Hybrid Recommendation System.pdf
Unit IV Knowledge and Hybrid Recommendation System.pdfUnit IV Knowledge and Hybrid Recommendation System.pdf
Unit IV Knowledge and Hybrid Recommendation System.pdf
 
How to Override Delete Function in Odoo 17
How to Override Delete Function in Odoo 17How to Override Delete Function in Odoo 17
How to Override Delete Function in Odoo 17
 
Q4 PPT-Health 9_Lesson 1 (Intentional Injuries).pptx
Q4 PPT-Health 9_Lesson 1 (Intentional Injuries).pptxQ4 PPT-Health 9_Lesson 1 (Intentional Injuries).pptx
Q4 PPT-Health 9_Lesson 1 (Intentional Injuries).pptx
 
AI in the project profession: examples of current use and roadmaps to adoptio...
AI in the project profession: examples of current use and roadmaps to adoptio...AI in the project profession: examples of current use and roadmaps to adoptio...
AI in the project profession: examples of current use and roadmaps to adoptio...
 
Air permeability control technique in paper making.docx
Air permeability control technique in paper making.docxAir permeability control technique in paper making.docx
Air permeability control technique in paper making.docx
 
4.2.24 The Black Panther Party for Self-Defense.pptx
4.2.24 The Black Panther Party for Self-Defense.pptx4.2.24 The Black Panther Party for Self-Defense.pptx
4.2.24 The Black Panther Party for Self-Defense.pptx
 
(Part 1) CHILDREN'S DISABILITIES AND EXCEPTIONALITIES.pdf
(Part 1) CHILDREN'S DISABILITIES AND EXCEPTIONALITIES.pdf(Part 1) CHILDREN'S DISABILITIES AND EXCEPTIONALITIES.pdf
(Part 1) CHILDREN'S DISABILITIES AND EXCEPTIONALITIES.pdf
 
Air Quality Presentation - EEH Chapter 10
Air Quality Presentation - EEH Chapter 10Air Quality Presentation - EEH Chapter 10
Air Quality Presentation - EEH Chapter 10
 

Concept of Structured Query Language (SQL) in SQL server as well as MySql. BBA 2nd Semester, Tribhuvan University.

  • 1. 1 By: Rohan Byanjankar Sainik Awasiya Mahavidyalaya, Sallaghari, Bhaktapur CONCEPT ON STRUCTURED QUERY LANGUAGE (SQL)
  • 2. 2  Structured Query Language (SQL) is the special purposed programming language,  Main purpose of SQL to access data in Relational Database Management System,  RDBMS is the most revered DBMS, and basis for SQL,  The data in RDBMS are recorded in relations or table,  Relation is the pre-defined rows and column, where column contains attributes, and tuples in rows,  Oracle, SQL Server, MySQL are the examples… Structured Query Language
  • 3. 3 Major Two Languages in RDBMS Data Definition Language Data Manipulation Language
  • 4. 4 • One of the fundamental requirements of SQL, • One is dumb in the SQL without knowledge of DDL, • Backbone of SQL, • Helps to develop overall design of database, • Helps to create, delete, and modify the database schema, • Not frequently used as database schema is not frequently changed, Data Definition Language (DDL)
  • 5. 5 • Create • Use • Drop • Alter Basic DDL Commands
  • 6. 6 One of the fundamental commands, Use to establish many new independent database in DBMS, Use to create table within newly established database or existing database, Syntax: - CREATE DATABASE SAMB - CREATE TABLE Students Create Command
  • 7. 7 One of the fundamental commands, Helps to work on the newly established or created database, Syntax: - USE SAMB Use Command One of the DDL commands, Used to delete column of a table, entire table, and entire database, We must use drop command with intense care, Syntax: - DROP TABLE Student - DROP DATABASE SAMB Drop Command
  • 8. 8 • Falls under the category of DDL command, • Used to change the structure of table without deleting or re-creating the table, • Syntax: 1. ALTER TABLE Student ADD Email_id VARCHAR(20) 2. ALTER TABLE Student DROP COLUMN Email_id Alter Command
  • 9. 9 • One of the fundamental requirements of SQL, • DML helps to work on RDBMS, • Helps to change the content of RDBMS, • Helps to insert, select, update and delete the database instances, • Frequently used as frequent modification is made in database, Data Manipulation Language (DML)
  • 10. 10 • Insert • Select • Update • Delete Basic DML Command
  • 11. 11 • Basic DML command, • Used to add new data in database, • The most frequently used, Syntax: • INERT INTO Student VALUES (0020, ‘Sujita Shrestha’, ‘BBA’, 16, ‘sujita98@gmail.com’) • INSERT INTO Student (sid, sname, grade) VALUES (0023, ‘Smiriti KC’, ‘BBA’) Insert Command
  • 12. 12 • Enables to select data from database, • Syntax: • To select all • SELECT * FROM Student • To select students with name staring from ‘S’ • SELECT * FROM Student where sname=‘s%’ • To select students according to ID in descending order • SELECT * FROM Student ORDER BY sid desc Select Command
  • 13. 13 • Used to update existing record in a table, • Syntax: • UPDATE table_name SET column1= Value1 • For Example: • To update salary to 1.5 times of existing salary of an employee with empid 19 • UPDATE tblemployee SET salary = 1.5*salary Update Command WHERE empid= 19
  • 14. 14 • Enables us to remove the selected tuple or entire tuple without making alter to the table, • Syntax: • DELETE FROM table_name WHERE column1= ‘Value1’ • For Example: • If Student with sid 0001 is needed to be removed from Student table, then • DELETE FROM Student Delete Command WHERE sid= 0001
  • 15. 15 • SQL View is a logical table, • Created from the existing table, • Virtual table based on real table, • Constraints of Base table is applicable in View also. • Any modification in base table is reflected in View. • User can Use DML commands once the view is created. SQL Views
  • 16. 16 CREATE VIEW View_name AS SELECT column1, column2, column3 FROM Table_1 WHERE column3= ‘Value1’ For Example: To create view from table Product (Pid, Pname, Cost Price, Selling Price, Manu_date, Exp_date, Category) to Beverage Department CREATE VIEW Beverage AS SELECT Pid, Pname, Selling Price, Manu_date, Exp_date FROM Product WHERE Category= ‘Beverage’ Syntax
  • 17. 17 Pid Pname Cost Price Selling Price Manu_date Exp_date Category 001 Parle-G 88 95 2014-01-05 2014-07-05 General 002 Coca-Cola 130 149 2013-12-09 2014-06-09 Beverage 003 Toberg 200 220 2013-11-14 2014-07-11 Beverage 004 Sunflow Oil 300 350 2013-08-08 2014-08-08 General Pid Pname Selling Price Manu_date Exp_date 002 Coca-Cola 149 2013-12-09 2014-06-09 003 Toberg 220 2013-11-14 2014-07-11 Product Beverage CREATE VIEW Beverage AS SELECT Pid, Pname, Selling Price, Manu_date, Exp_date FROM Product WHERE Category= ‘Beverage’ Beverage Department
  • 18. 18 • A database index is a data structure that improves the speed of data retrieval operations on a database table, • used to quickly locate data without having to search every row Syntax: CREATE INDEX index_name ON Table_name (column1) Index
  • 19. 19 For Example: To create INDEX on table Library (ISBN, Bname, Price, Author) CREATE INDEX Book_index ON Library (ISBN) Contd… ISBN Bname Price Author 000-124-456 The Old Man and The Sea Rs. 97 Ernest Hemingway 978-1-85326-067-4 Far from the Madding Crowd Rs. 200 Thomas Hardy 978-81-291-0818-0 One Night @ The Call Center Rs. 200 Chetan Bhagat Library
  • 20. 20 • Those functions that perform a calculation on a set of values and return a single value. • MAX, MIN, AVG, COUNT are the examples… Syntax: 1. SELECT Column1, MAX(Column2) AS MAX_Price FROM Tbleproduct 2. SELECT Column1, MIN(Column2) AS MIN_Price FROM Tbleproduct 3. SELECT Column1, AVG(Column2) AS AVG_Price FROM Tbleproduct Aggregate Function
  • 21. 21 SELECT Category, MAX(Selling_Price) AS MAX_SP FROM Product GROUP BY Category Contd… Pid Pname Cost_Price Selling_Price Manu_date Exp_date Category 001 Parle-G 88 95 2014-01-05 2014-07-05 General 002 Coca-Cola 130 149 2013-12-09 2014-06-09 Beverage 003 Tuborg 200 220 2013-11-14 2014-07-11 Beverage 004 Sunflow Oil 300 350 2013-08-08 2014-08-08 General Product Category MAX_SP Beverage 220 General 350
  • 22. 22 • SQL join is the operation that enables us to get the combined Values of attributes of two tables, • The most common type of join is ‘Inner Join’. Syntax: SELECT column1, column2, column3, column5, column6 FROM Table1 INNER JOIN Table2 ON Table1.Column1=Table2.column5 Note: Data type of column1 and column5 must be identical Joins
  • 23. 23 ISBN Bname Price Author 000-124-456 The Old Man and The Sea Rs. 97 Ernest Hemingway 978-1-85326-067-4 Far from the Madding Crowd Rs. 200 Thomas Hardy 978-81-291-0818-0 One Night @ The Call Center Rs. 200 Chetan Bhagat ID Sname Grade ISBN1 0001 Sanjay Sharma BBA 978-81-291-0818-0 0002 Sushil Shrestha BSC 000-124-456 0030 Samikshaya Sharma BBA 978-1-85326-067-4 Library Student SELECT ISBN, Bname, ID, Sname, Grade, ISBN1 FROM Library INNER JOIN Student ON Library.ISBN= Student.ISBN1 ISBN Bname ID Sname Grade 978-81-291-0818-0 One Night @ The Call Center 0001 Sanjay Sharma BBA 000-124-456 The Old Man and The Sea 0002 Sushil Shrestha BSC 978-1-85326-067-4 Far from the Madding Crowd 0030 Samikshaya Sharma BBA
  • 24. 24 Create Table Student with following attributes: SQL Question: ID Number Primary Key Name Text Not Null and length<40 Age Number >17 and <25 Grade Text BBA or BSC Not Null Email Text Unique Not Null Contact Text Not Null Length= 7 or 10 Address Text Not Null CREATE TABLE Student ( ID INT, Sname VARCHAR (50) NOT NULL, Age INT, Grade VARCHAR (8) NOT NULL, Email_id VARCHAR (30) UNIQUE NOT NULL, Contact VARCHAR (13) NOT NULL, Address VARCHAR (30) NOT NULL, CONSTRAINT pk_id PRIMARY KEY (ID), CONSTRAINT ch_values CHECK (LEN(Sname)<40), CONSTRAINT ch_values1 CHECK(Grade IN (‘BBA’,’BSC’)), CONSTRAINT ch_values2 CHECK (LEN(Contact)=7 OR LEN(Contact)=10));