SlideShare a Scribd company logo
1 of 17
Download to read offline
3
Queries for Data Definition and Data Manipulation Language
1. Table Student:
Create a table using create command:
Create table Student
(Rollno int, Name char(10), F_name char(10), City char(10), Contact_no num(10), Email_id varchar(15));
Use of Desc command:
Decs students;
Use of Alter command:
alter table students add(course varchar(10));
alter table students modify(roll_no varchar(20));
alter table students drop(permanent_address);
4
Use of insert command:
insert into students values('101','01jul96','mohit tripathi','tara Chandra
tripathi','lalkuan',7351982624,'mohit07tripathi@gmail.com','kaushaliya tripathi' ');
insert into students values('102','21mar97','megha tripathi','tara Chandra
tripathi','lalkuan',9690723702,'mohit01tripathi@gmail.com','kaushaliya tripathi');
insert into students values('103','23sep99','gaurav tripathi','tara Chandra
tripathi','lalkuan',8954290592,'mohittripathi95@gmail.com','kaushaliya tripathi');
Use of select * command:
select *from Student;
5
Use of update command:
update students set address='rampur' where address='haldwani';
Use of delete command:
delete from students where roll_no=108;
2. Table Faculty:
Create table Faculty
(fid varchar(20) primary key,fname varchar(20) not null,fContact_no number(10) not null,
fEmail_id varchar(25) not null,fsalary int check(fsalary>30000),fcourse char(10), fdesignation char(15));
Use of Insert command:
insert into Faculty values('f01','Ajay','12345','abc@gmail.com','32000','MCA','Asstprof');
insert into Faculty values('f02','Juhi','23456','bcd@gmail.com','36000','BCA','Asstprof');
insert into Faculty values('f03','Rajesh','34567','cde@gmail.com','31000','MCA''Asstprof');
6
Use of Select command:
select *from Faculty;
Queries
A. Retrieve the name of faculties earning more than Rs.50000.
select fname from faculty where fsalary >50000;
B. Retrieve the name of faculty who are teaching MCA and are Asstprof.
select fname from faculty where fcourse='MCA' and fdesignation='Asstprof';
C. Retrieve the e-mail and course of juhi and rajesh.
select f_email_id,f_course from faculty
where f_name='juhi' or f_name='rajesh';
7
D. Change the designation of aarti from asstprof to lecturer.
update faculty set f_designation='lacturer'
where f_name='aarti';
E. Change the course cse to cs and e
update faculty set f_course='cs&e'
where f_course='cse';
F. Retrieve the name of employees who have a gmail account.
select fname from Faculty where fEmail_id like '%@gmail.com';
G. Retrieve all the details of faculties whose name start with letter V.
select *from Faculty where fname like 'V%';
8
H. Remove faculty who is earning more than Rs.71000.
delete from Faculty where fsalary >71000
I. Retrieve all the details of the person who is provided a number ‘23456’.
select fname,fEmail_id,fsalary,fcourse,fdesignation from Faculty where fcontact_no='23456';
3. Table Staff:
Create table Staff
(sno varchar(10), fname char(10), lname char(10), salary number(10,2), position char(20));
desc Staff;
insert into Staff values('SL100','John','White','30000.00','Manager');
insert into Staff values('SL101','Susan','Brand','24000.00','Manager');
select *from Staff;
9
Queries based on Aggregate functions for table Staff:
1. select sum(salary) as sum_salary from Staff where position='Manager';
2. select sum(salary) as sum_salary from Staff;
3. select sum(salary) as sum_salary from Staff where position='Project Manager';
4. select avg(Distinct salary) as avg_salary from Staff where Staff.position='Project Manager';
5. select avg(salary) as avg_salary from Staff where Staff.position='Project Manager';
6. select sum(Distinct salary) as sum_salary from Staff;
7. select min(salary)as min_salary from Staff;
8. select max(salary)as max_salary from Staff;
9. select fname from Staff where salary in(select min(salary) from Staff);
10
10. select fname from Staff where salary in(select max(salary) from Staff);
11. select count(sno) as sno_count from Staff where Staff.position='Project Manager';
12. select count(sno) as sno_count from Staff where salary>9000;
13. select count(sno) as sno_count,sum(salary) as sum_salary from Staff where Staff.position='Manager';
Updation on table Staff:
alter table Staff add(bno varchar(10));
update Staff set bno='B3' where fname='John';
update Staff set bno='B5' where fname='Susan';
14. select bno,count(sno) as count,sum(salary) as sum from Staff group by bno;
15. select bno,count(sno) as count,sum(salary) as sum from Staff group by bno order by bno;
11
4. Table Address, People1, PhoneNumbers1:
create table Address
(AddressID int primary key, Company char(10),
Address number(10),Zip number(10));
describe Address;
create table People1
(Id int primary key,Name char(10),
AddressId int references Address(AddressID));
describe People1;
create table PhoneNumbers1
(PhoneID int primary key,Id int references People(Id),Phone number(10));
describe PhoneNumbers1;
insert into Address values('1','ABC','123','12345');
insert into Address values('2','XYZ','456','14454');
insert into Address values('3','PDQ','789','14423');
select *from Address;
select *from People1;
select *from PhoneNumbers1;
12
Queries based on foreign key (or Sub-queries) for above tables:
1. Select name, PhoneID, Company from People1, PhoneNumbers1, Address where
Address.AddressID=People1.AddressID and People1.Id=PhoneNumbers1.Id;
2. select Company,Zip from Address, People1 where name='Jane' and Address.AddressID=People1.AddressID;
3. select Address,Company,Phone from Address,PhoneNumbers1,People1 where name='Chris' and
Address.AddressID=People1.AddressID and People1.Id=PhoneNumbers1.Id;
4. select Company,Zip from Address where AddressId in(select AddressId from People1 where name='Jane');
5. select Address,Company,Phone from Address,PhoneNumbers1 where AddressId in(select AddressId from
People1 where name='Chris');
6. select Phone from Phonenumbers1 where ID in(select ID from People1 where name='Joe');
7. select Name from People1,Address where Company!='ABC' and Address.AddressId=People1.AddressId;
13
8. select Name from People1 where AddressId in(select AddressId from Address where Company!='ABC');
5. Table Branch, Borrow1, Customer, Deposit:
create table Branch(BName char(10) primary key,City char(10));
create table Borrow1
(LoanNo number(10) primary key ,CName char(10), Bname char(10) references Branch(BName),Amount
number(10));
create table Customer(CName char(10) primary key,City char(10));
create table Deposit
(AccountNo number(10) primary key,CName char(10) references Customer(CName),BName char(10),Amount
number(10),ADate date);
insert into Branch values('Vrce','Nagpur');
insert into Branch values('Ajni','Nagpur');
select* from Branch;
select* from Borrow1;
14
select* from Customer;
Select* from Deposit;
Queries related to above tables:
select CName from Deposit where BName in(select BName from Branch where Branch.city='Delhi') and
CName in(select CName from Customer where Customer.City='Mumbai');
select CName from Deposit where BName in (select BName from Branch where CName in(select CName from
Customer where Branch.City=Customer.City));
15
PL/SQL
Programmes of VIEW:
Create view:
1. create view staff_1 as select f_name,position,salary from staff;
2. select * from staff_1;
3. desc staff_1;
16
4. Insert into staff_1 values('mohit','director',100000);
5. select * from staff_1 where position='manager';
6. desc staff;
7. alter view staff_1 add('s_name',varchar);
8. update staff_1 set f_name='ratnesh' where position='director';
17
9. create view staff2 as select position,salary from staff;
10. select * from staff2;
11. delete from staff_1 where f_name='ratnesh';
12. drop view staff2;
18
Write a pl/sql block to print “HELLO” five time.
Write a pl/sql block to print a name:
19
Write a pl/sql block to print a predefine error:
TRIGGERS
Creating a trigger

More Related Content

Recently uploaded

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 

Recently uploaded (20)

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Very simple queries of DBMS

  • 1. 3 Queries for Data Definition and Data Manipulation Language 1. Table Student: Create a table using create command: Create table Student (Rollno int, Name char(10), F_name char(10), City char(10), Contact_no num(10), Email_id varchar(15)); Use of Desc command: Decs students; Use of Alter command: alter table students add(course varchar(10)); alter table students modify(roll_no varchar(20)); alter table students drop(permanent_address);
  • 2. 4 Use of insert command: insert into students values('101','01jul96','mohit tripathi','tara Chandra tripathi','lalkuan',7351982624,'mohit07tripathi@gmail.com','kaushaliya tripathi' '); insert into students values('102','21mar97','megha tripathi','tara Chandra tripathi','lalkuan',9690723702,'mohit01tripathi@gmail.com','kaushaliya tripathi'); insert into students values('103','23sep99','gaurav tripathi','tara Chandra tripathi','lalkuan',8954290592,'mohittripathi95@gmail.com','kaushaliya tripathi'); Use of select * command: select *from Student;
  • 3. 5 Use of update command: update students set address='rampur' where address='haldwani'; Use of delete command: delete from students where roll_no=108; 2. Table Faculty: Create table Faculty (fid varchar(20) primary key,fname varchar(20) not null,fContact_no number(10) not null, fEmail_id varchar(25) not null,fsalary int check(fsalary>30000),fcourse char(10), fdesignation char(15)); Use of Insert command: insert into Faculty values('f01','Ajay','12345','abc@gmail.com','32000','MCA','Asstprof'); insert into Faculty values('f02','Juhi','23456','bcd@gmail.com','36000','BCA','Asstprof'); insert into Faculty values('f03','Rajesh','34567','cde@gmail.com','31000','MCA''Asstprof');
  • 4. 6 Use of Select command: select *from Faculty; Queries A. Retrieve the name of faculties earning more than Rs.50000. select fname from faculty where fsalary >50000; B. Retrieve the name of faculty who are teaching MCA and are Asstprof. select fname from faculty where fcourse='MCA' and fdesignation='Asstprof'; C. Retrieve the e-mail and course of juhi and rajesh. select f_email_id,f_course from faculty where f_name='juhi' or f_name='rajesh';
  • 5. 7 D. Change the designation of aarti from asstprof to lecturer. update faculty set f_designation='lacturer' where f_name='aarti'; E. Change the course cse to cs and e update faculty set f_course='cs&e' where f_course='cse'; F. Retrieve the name of employees who have a gmail account. select fname from Faculty where fEmail_id like '%@gmail.com'; G. Retrieve all the details of faculties whose name start with letter V. select *from Faculty where fname like 'V%';
  • 6. 8 H. Remove faculty who is earning more than Rs.71000. delete from Faculty where fsalary >71000 I. Retrieve all the details of the person who is provided a number ‘23456’. select fname,fEmail_id,fsalary,fcourse,fdesignation from Faculty where fcontact_no='23456'; 3. Table Staff: Create table Staff (sno varchar(10), fname char(10), lname char(10), salary number(10,2), position char(20)); desc Staff; insert into Staff values('SL100','John','White','30000.00','Manager'); insert into Staff values('SL101','Susan','Brand','24000.00','Manager'); select *from Staff;
  • 7. 9 Queries based on Aggregate functions for table Staff: 1. select sum(salary) as sum_salary from Staff where position='Manager'; 2. select sum(salary) as sum_salary from Staff; 3. select sum(salary) as sum_salary from Staff where position='Project Manager'; 4. select avg(Distinct salary) as avg_salary from Staff where Staff.position='Project Manager'; 5. select avg(salary) as avg_salary from Staff where Staff.position='Project Manager'; 6. select sum(Distinct salary) as sum_salary from Staff; 7. select min(salary)as min_salary from Staff; 8. select max(salary)as max_salary from Staff; 9. select fname from Staff where salary in(select min(salary) from Staff);
  • 8. 10 10. select fname from Staff where salary in(select max(salary) from Staff); 11. select count(sno) as sno_count from Staff where Staff.position='Project Manager'; 12. select count(sno) as sno_count from Staff where salary>9000; 13. select count(sno) as sno_count,sum(salary) as sum_salary from Staff where Staff.position='Manager'; Updation on table Staff: alter table Staff add(bno varchar(10)); update Staff set bno='B3' where fname='John'; update Staff set bno='B5' where fname='Susan'; 14. select bno,count(sno) as count,sum(salary) as sum from Staff group by bno; 15. select bno,count(sno) as count,sum(salary) as sum from Staff group by bno order by bno;
  • 9. 11 4. Table Address, People1, PhoneNumbers1: create table Address (AddressID int primary key, Company char(10), Address number(10),Zip number(10)); describe Address; create table People1 (Id int primary key,Name char(10), AddressId int references Address(AddressID)); describe People1; create table PhoneNumbers1 (PhoneID int primary key,Id int references People(Id),Phone number(10)); describe PhoneNumbers1; insert into Address values('1','ABC','123','12345'); insert into Address values('2','XYZ','456','14454'); insert into Address values('3','PDQ','789','14423'); select *from Address; select *from People1; select *from PhoneNumbers1;
  • 10. 12 Queries based on foreign key (or Sub-queries) for above tables: 1. Select name, PhoneID, Company from People1, PhoneNumbers1, Address where Address.AddressID=People1.AddressID and People1.Id=PhoneNumbers1.Id; 2. select Company,Zip from Address, People1 where name='Jane' and Address.AddressID=People1.AddressID; 3. select Address,Company,Phone from Address,PhoneNumbers1,People1 where name='Chris' and Address.AddressID=People1.AddressID and People1.Id=PhoneNumbers1.Id; 4. select Company,Zip from Address where AddressId in(select AddressId from People1 where name='Jane'); 5. select Address,Company,Phone from Address,PhoneNumbers1 where AddressId in(select AddressId from People1 where name='Chris'); 6. select Phone from Phonenumbers1 where ID in(select ID from People1 where name='Joe'); 7. select Name from People1,Address where Company!='ABC' and Address.AddressId=People1.AddressId;
  • 11. 13 8. select Name from People1 where AddressId in(select AddressId from Address where Company!='ABC'); 5. Table Branch, Borrow1, Customer, Deposit: create table Branch(BName char(10) primary key,City char(10)); create table Borrow1 (LoanNo number(10) primary key ,CName char(10), Bname char(10) references Branch(BName),Amount number(10)); create table Customer(CName char(10) primary key,City char(10)); create table Deposit (AccountNo number(10) primary key,CName char(10) references Customer(CName),BName char(10),Amount number(10),ADate date); insert into Branch values('Vrce','Nagpur'); insert into Branch values('Ajni','Nagpur'); select* from Branch; select* from Borrow1;
  • 12. 14 select* from Customer; Select* from Deposit; Queries related to above tables: select CName from Deposit where BName in(select BName from Branch where Branch.city='Delhi') and CName in(select CName from Customer where Customer.City='Mumbai'); select CName from Deposit where BName in (select BName from Branch where CName in(select CName from Customer where Branch.City=Customer.City));
  • 13. 15 PL/SQL Programmes of VIEW: Create view: 1. create view staff_1 as select f_name,position,salary from staff; 2. select * from staff_1; 3. desc staff_1;
  • 14. 16 4. Insert into staff_1 values('mohit','director',100000); 5. select * from staff_1 where position='manager'; 6. desc staff; 7. alter view staff_1 add('s_name',varchar); 8. update staff_1 set f_name='ratnesh' where position='director';
  • 15. 17 9. create view staff2 as select position,salary from staff; 10. select * from staff2; 11. delete from staff_1 where f_name='ratnesh'; 12. drop view staff2;
  • 16. 18 Write a pl/sql block to print “HELLO” five time. Write a pl/sql block to print a name:
  • 17. 19 Write a pl/sql block to print a predefine error: TRIGGERS Creating a trigger