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

PPTX
Inner join and outer join
PPTX
Bootcamp sql fundamentals bootcamp_part4
PPT
Unit 1.3 Introduction to Programming (Part 2)
PPT
Sql joins
PPSX
Join query
PPTX
SQL JOIN
PPTX
SQL JOINS- Reena P V
PPTX
Sql joins inner join self join outer joins
Inner join and outer join
Bootcamp sql fundamentals bootcamp_part4
Unit 1.3 Introduction to Programming (Part 2)
Sql joins
Join query
SQL JOIN
SQL JOINS- Reena P V
Sql joins inner join self join outer joins

Viewers also liked (9)

PPTX
6. electronic payment systems
PPT
Chp7 intranet
PPTX
Electronic payment System
PPT
Chp8 electronic payment system
PPTX
Electronic payment system
PPTX
Electronic Payment Systems (EPS)
PPT
Electronic Payment System
PPTX
The electronic payment systems
PDF
electronic_payment_system_in_korea_eng
6. electronic payment systems
Chp7 intranet
Electronic payment System
Chp8 electronic payment system
Electronic payment system
Electronic Payment Systems (EPS)
Electronic Payment System
The electronic payment systems
electronic_payment_system_in_korea_eng
Ad

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

PPTX
PPT
Advanced Sql Training
PPTX
Structured Query Language(SQL)
PPTX
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
PDF
Sql wksht-6
PPT
SQL200.2 Module 2
PDF
SQL Overview
PPTX
OracleSQLraining.pptx
PPTX
MS Sql Server: Joining Databases
PPTX
MS SQLSERVER:Joining Databases
PPTX
MS SQL SERVER: Joining Databases
PDF
MODULE 1.pdf foundations of data science for final
PPTX
Java class 8
PPT
SQL.ppt
PPTX
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
PDF
Sql overview-1232931296681161-1
PPTX
advanced database management system by uni
PPTX
Day-2 SQL Theory_V1.pptx
Advanced Sql Training
Structured Query Language(SQL)
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Sql wksht-6
SQL200.2 Module 2
SQL Overview
OracleSQLraining.pptx
MS Sql Server: Joining Databases
MS SQLSERVER:Joining Databases
MS SQL SERVER: Joining Databases
MODULE 1.pdf foundations of data science for final
Java class 8
SQL.ppt
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
Sql overview-1232931296681161-1
advanced database management system by uni
Day-2 SQL Theory_V1.pptx
Ad

More from Sunil Kumar Gunasekaran (20)

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

Recently uploaded (20)

PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPTX
2018-HIPAA-Renewal-Training for executives
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Consumable AI The What, Why & How for Small Teams.pdf
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPT
What is a Computer? Input Devices /output devices
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
DOCX
search engine optimization ppt fir known well about this
PPTX
Modernising the Digital Integration Hub
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
Flame analysis and combustion estimation using large language and vision assi...
PPTX
Configure Apache Mutual Authentication
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
A review of recent deep learning applications in wood surface defect identifi...
Enhancing emotion recognition model for a student engagement use case through...
Hindi spoken digit analysis for native and non-native speakers
sbt 2.0: go big (Scala Days 2025 edition)
A proposed approach for plagiarism detection in Myanmar Unicode text
2018-HIPAA-Renewal-Training for executives
Module 1.ppt Iot fundamentals and Architecture
Consumable AI The What, Why & How for Small Teams.pdf
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
What is a Computer? Input Devices /output devices
NewMind AI Weekly Chronicles – August ’25 Week III
search engine optimization ppt fir known well about this
Modernising the Digital Integration Hub
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Flame analysis and combustion estimation using large language and vision assi...
Configure Apache Mutual Authentication
A comparative study of natural language inference in Swahili using monolingua...
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...

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