SlideShare a Scribd company logo
SQL Commands executed in
SQL Plus
Sunil Kumar Gunasekaran
Creating table PERSONS1013 with the following Attribute names

Altering the Column name of the table P_ID to include NOT NULL and PRIMARY
KEY status

Adding another column SALARY with data type as Number;

Page 1
After all the modifications done to the table

Sample of records into the table using INSERT command
Inse

Page 2
The table with the values loaded is shown below

Page 3
Getting the details of the record having the highest salary

Getting the name of the person with the highest salary

Getting the name of the person with minimum salary

Page 4
Getting the names of persons with salary greater than the average salary
The nested statements are used when there is one to one relationship between
person and salary.

Need to work out on Inner Join Outer Join and Natural Join and other functions and update here to be
done or revised before any interview.

Dropping the whole table using DROP DDL command

Deleting a particular record

Using Group by with a function to group by the entities based on the function;
Note that only Sum and average require group by since

Page 5
This is the Orders table for the above GROUP BY function execution.
The requirement is that there need to be a customer and many orders placed by him and hence many
orderprices. If we want info of the max min avg sum of the orderprices placed by each customer, then
use group by along with the functions.
Usage of Having
Having and group by are used in one t omany relationship between customer and orderprice
This is similar to where only that the aggregate functions can be used in having and aggregate functions
cannot be used in where.

Page 6
Note that the having can hold expressions involving aggregate functions
INNER JOIN
There are two tables. Table 1 having customer firstr name last name address and city and P_ID;
The second table has details of order i.eorderid, order number and P_ID.
We need customer first name and customer last name and the order number of customers who made
orders present in the Persons table. Hence we use inner join for this.

JOINS
Consider the following Persons table and Orders table. They have in common PID
Customer Table has PIDs 1 2 and 3
Orders Table has PIDs 3 3 1 1 and 15
We are going to make a join based on this common key.
When the join is made, a appended table containing all the column headings appear.
PID LN FN Add City O_IdONumber PID
First the common elements are filled in the above table. This forms inner join
If the remnants of first table is added to the common records, then it is LEFT JOIN
If remnants of right table is added to the common records ,then it is RIGHT JOIN
Page 7
If remnants of left and right are added to the common records, then it is FULL JOIN.
In all cases remember the appended table in mind and work out accordingly.

Page 8

More Related Content

Viewers also liked (9)

PPTX
6. electronic payment systems
Pratap Tirkey
 
PPT
Chp7 intranet
Engr Razaque
 
PPTX
Electronic payment System
Mohammad Waqas
 
PPT
Chp8 electronic payment system
Engr Razaque
 
PPTX
Electronic payment system
60ml
 
PPTX
Electronic Payment Systems (EPS)
Sahan Walpitagamage
 
PPT
Electronic Payment System
Ritesh Goyal
 
PPTX
The electronic payment systems
Vishal Singh
 
PDF
electronic_payment_system_in_korea_eng
Frank Mercado
 
6. electronic payment systems
Pratap Tirkey
 
Chp7 intranet
Engr Razaque
 
Electronic payment System
Mohammad Waqas
 
Chp8 electronic payment system
Engr Razaque
 
Electronic payment system
60ml
 
Electronic Payment Systems (EPS)
Sahan Walpitagamage
 
Electronic Payment System
Ritesh Goyal
 
The electronic payment systems
Vishal Singh
 
electronic_payment_system_in_korea_eng
Frank Mercado
 

Similar to Sql commands worked out in sql plus with screen shots (20)

PPTX
Spufi
Anil Bharti
 
PPT
Advanced Sql Training
bixxman
 
PPTX
Structured Query Language(SQL)
PadmapriyaA6
 
PPTX
Introduction to mysql part 2
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Sql wksht-6
Mukesh Tekwani
 
PPT
SQL200.2 Module 2
Dan D'Urso
 
PDF
SQL Overview
Stewart Rogers
 
PPTX
OracleSQLraining.pptx
Rajendra Jain
 
PPTX
MS Sql Server: Joining Databases
DataminingTools Inc
 
PPTX
MS SQLSERVER:Joining Databases
sqlserver content
 
PPTX
MS SQL SERVER: Joining Databases
sqlserver content
 
PPTX
Java class 8
Edureka!
 
PPT
SQL.ppt
Ranjit273515
 
PPTX
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
jaijsr12345
 
PDF
Sql overview-1232931296681161-1
sagaroceanic11
 
PPTX
advanced database management system by uni
VaibhavSrivastav52
 
PPTX
Day-2 SQL Theory_V1.pptx
uzmasulthana3
 
PPTX
More Complex SQL and Concurrency ControlModule 4.pptx
bgscseise
 
Advanced Sql Training
bixxman
 
Structured Query Language(SQL)
PadmapriyaA6
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
Sql wksht-6
Mukesh Tekwani
 
SQL200.2 Module 2
Dan D'Urso
 
SQL Overview
Stewart Rogers
 
OracleSQLraining.pptx
Rajendra Jain
 
MS Sql Server: Joining Databases
DataminingTools Inc
 
MS SQLSERVER:Joining Databases
sqlserver content
 
MS SQL SERVER: Joining Databases
sqlserver content
 
Java class 8
Edureka!
 
SQL.ppt
Ranjit273515
 
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
jaijsr12345
 
Sql overview-1232931296681161-1
sagaroceanic11
 
advanced database management system by uni
VaibhavSrivastav52
 
Day-2 SQL Theory_V1.pptx
uzmasulthana3
 
More Complex SQL and Concurrency ControlModule 4.pptx
bgscseise
 
Ad

More from Sunil Kumar Gunasekaran (20)

DOCX
CQL - Cassandra commands Notes
Sunil Kumar Gunasekaran
 
DOCX
Java J2EE Complete Syllabus Checklist
Sunil Kumar Gunasekaran
 
PDF
Amazon search test case document
Sunil Kumar Gunasekaran
 
DOC
Actual test case document
Sunil Kumar Gunasekaran
 
DOC
Sample Technical Requirement Document (TRD)
Sunil Kumar Gunasekaran
 
DOCX
Sql reference from w3 schools
Sunil Kumar Gunasekaran
 
DOCX
Wells fargo banking system ER Diagram
Sunil Kumar Gunasekaran
 
DOC
Business Requirements Document for Acounts Payable System
Sunil Kumar Gunasekaran
 
DOCX
Automation Testing Syllabus - Checklist
Sunil Kumar Gunasekaran
 
DOCX
Unix made easy
Sunil Kumar Gunasekaran
 
PDF
Test process - Important Concepts
Sunil Kumar Gunasekaran
 
DOCX
Testing http methods using Telnet
Sunil Kumar Gunasekaran
 
PDF
Test Life Cycle - Presentation - Important concepts covered
Sunil Kumar Gunasekaran
 
DOCX
Scrum writeup - Agile
Sunil Kumar Gunasekaran
 
DOCX
Scrum, V Model and RUP Models Overview
Sunil Kumar Gunasekaran
 
DOCX
PERL for QA - Important Commands and applications
Sunil Kumar Gunasekaran
 
DOCX
JAVA Notes - All major concepts covered with examples
Sunil Kumar Gunasekaran
 
DOCX
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Sunil Kumar Gunasekaran
 
DOCX
Fitnesse user acceptance test - Presentation
Sunil Kumar Gunasekaran
 
CQL - Cassandra commands Notes
Sunil Kumar Gunasekaran
 
Java J2EE Complete Syllabus Checklist
Sunil Kumar Gunasekaran
 
Amazon search test case document
Sunil Kumar Gunasekaran
 
Actual test case document
Sunil Kumar Gunasekaran
 
Sample Technical Requirement Document (TRD)
Sunil Kumar Gunasekaran
 
Sql reference from w3 schools
Sunil Kumar Gunasekaran
 
Wells fargo banking system ER Diagram
Sunil Kumar Gunasekaran
 
Business Requirements Document for Acounts Payable System
Sunil Kumar Gunasekaran
 
Automation Testing Syllabus - Checklist
Sunil Kumar Gunasekaran
 
Unix made easy
Sunil Kumar Gunasekaran
 
Test process - Important Concepts
Sunil Kumar Gunasekaran
 
Testing http methods using Telnet
Sunil Kumar Gunasekaran
 
Test Life Cycle - Presentation - Important concepts covered
Sunil Kumar Gunasekaran
 
Scrum writeup - Agile
Sunil Kumar Gunasekaran
 
Scrum, V Model and RUP Models Overview
Sunil Kumar Gunasekaran
 
PERL for QA - Important Commands and applications
Sunil Kumar Gunasekaran
 
JAVA Notes - All major concepts covered with examples
Sunil Kumar Gunasekaran
 
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Sunil Kumar Gunasekaran
 
Fitnesse user acceptance test - Presentation
Sunil Kumar Gunasekaran
 
Ad

Recently uploaded (20)

PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Top Managed Service Providers in Los Angeles
Captain IT
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 

Sql commands worked out in sql plus with screen shots

  • 1. SQL Commands executed in SQL Plus Sunil Kumar Gunasekaran
  • 2. Creating table PERSONS1013 with the following Attribute names Altering the Column name of the table P_ID to include NOT NULL and PRIMARY KEY status Adding another column SALARY with data type as Number; Page 1
  • 3. After all the modifications done to the table Sample of records into the table using INSERT command Inse Page 2
  • 4. The table with the values loaded is shown below Page 3
  • 5. Getting the details of the record having the highest salary Getting the name of the person with the highest salary Getting the name of the person with minimum salary Page 4
  • 6. Getting the names of persons with salary greater than the average salary The nested statements are used when there is one to one relationship between person and salary. Need to work out on Inner Join Outer Join and Natural Join and other functions and update here to be done or revised before any interview. Dropping the whole table using DROP DDL command Deleting a particular record Using Group by with a function to group by the entities based on the function; Note that only Sum and average require group by since Page 5
  • 7. This is the Orders table for the above GROUP BY function execution. The requirement is that there need to be a customer and many orders placed by him and hence many orderprices. If we want info of the max min avg sum of the orderprices placed by each customer, then use group by along with the functions. Usage of Having Having and group by are used in one t omany relationship between customer and orderprice This is similar to where only that the aggregate functions can be used in having and aggregate functions cannot be used in where. Page 6
  • 8. Note that the having can hold expressions involving aggregate functions INNER JOIN There are two tables. Table 1 having customer firstr name last name address and city and P_ID; The second table has details of order i.eorderid, order number and P_ID. We need customer first name and customer last name and the order number of customers who made orders present in the Persons table. Hence we use inner join for this. JOINS Consider the following Persons table and Orders table. They have in common PID Customer Table has PIDs 1 2 and 3 Orders Table has PIDs 3 3 1 1 and 15 We are going to make a join based on this common key. When the join is made, a appended table containing all the column headings appear. PID LN FN Add City O_IdONumber PID First the common elements are filled in the above table. This forms inner join If the remnants of first table is added to the common records, then it is LEFT JOIN If remnants of right table is added to the common records ,then it is RIGHT JOIN Page 7
  • 9. If remnants of left and right are added to the common records, then it is FULL JOIN. In all cases remember the appended table in mind and work out accordingly. Page 8