DBMS Lab Manual 7-2-2016
DBMS Lab Manual 7-2-2016
DBMS Lab Manual 7-2-2016
COURSE CONTENTS
UNIT-1
Introduction to Databases: Introduction, An Example, Characteristics of 11 Hrs.
Database approach, Advantages of using DBMS approach, When not to use a
DBMS.
Database System Concepts and Architecture: Data models, Schemas and
instances, Three schema architecture and data independence, Database languages
and interfaces, The database system environment.
SQL: SQL Data Definition and Data Types specifying basic constraints in SQL,
Basic retrieval queries in SQL, Insert, Delete and Update statements in SQL,
Additional features of SQL, More complex SQL Queries, Specifying Constraints
as Assertion and Trigger, Views (Virtual Tables) in SQL, Schema Change
Statement in SQL.
UNIT-2
Relational Data Model and Relational Database Constraints: Relational 11 Hrs.
Model Concepts, Relational Model Constraints and Relational Database Schemas,
Update Operations, Transactions and Dealing with Constraint Violations.
Relational Algebra: Unary Relational Operations, SELECT and PROJECT,
Relational Algebra Operations from Set Theory, Binary Relational Operations:
JOIN and DIVISION, Additional Relational Operations, Examples of Queries in
Relational Algebra.
Data Modeling using the Entity-Relationship(ER) model: Using High-Level
conceptual Data Models for Database Design, A sample Database Application,
Entity types, Entity Sets, Attributes and Keys, Relationship Types, Relationship
Sets, Roles and Structural Constraints, Weak Entity types, Refining the ER
Design, ER Diagrams, Naming Conventions and Design Issues, Relationship
Types of Degree Higher than Two, Database Design using ER-toRelational
Mapping.
UNIT-3
Database Design Theory and Normalization: Informal Design Guidelines for 9 Hrs.
Relation Schemas, Functional Dependencies, Normal Forms Based on Primary
Keys, General Definitions of Second and Third Normal Forms, Boyce-Codd
Normal Form, Multi-valued Dependencies and Fourth Normal Form, Join
Dependencies and Fifth Normal Form.
UNIT-4
Transaction Processing, Concurrency Control, and Recovery: Introduction to 8 Hrs.
Transaction Processing, Transaction and System Concepts, Desirable Properties
of Transactions,Characterizing Schedules Based on Recoverability,
Characterizing Schedules Based on Serializability, Two-Phase Locking
Techniques for Concurrency Control, Recovery Concepts, NO-UNDO/REDO
Recovery Techniques based on Deferred Update, Recovery Techniques Based on
Immediate Update, Shadow Paging, The ARIES Recovery
References:
Text Books:
1. Fundamental of Database Systems by RamezElmasri and Shamkant B Navathe, Sixth
Edition, Addison Wesley, 2011.
2. Database System Concepts, Sixth Edition,AbrahamSilberschatz, Henry F. Korth, S.
Sudarshan : Tata McGraw-Hill,2010
Reference Books:
1. An Introduction to Database Systems by C.J. Date, A.Kannan, S.Swamynathan, 8th
Edition, Pearson Education, 2006.
2.Database Systems: The Complete Book, Second Edition, Hector Garcia-Molina,Jeffrey
D.Ullman, Jennifer Widom , Pearson Education, 2001
E- Books:
1. Introduction to structured Query Language (SQL)
2. An Introduction to Relational Database Theory by Hugh Darwen
3. Database Management System by Raghu Ramakrishnan
MOOCs:
1. http://nptel.ac.in/courses/IIT-MADRAS/Intro_to_Database_Systems_Design
2.http://www.iitg.ernet.in/awekar/teaching/cs344fall11/
3. www.w3schools.com/sql/
PROGRAM OUTCOMES
COURSE OBJECTIVES
CO-PO MAPPING
3. Reading data from already existing database table and displaying it using form grid. Note:
Database table should contain Student name, USN, Department name and Semester.
4. Insert the new record into the existing database table by accepting the new record information
through form and Update any of the existing database record. Note: Database table should
contain Student name, USN, Department name and Semester.
5. Delete the existing record from the database table against USN by accepting it through the
form text box and Search the student database records.
Part B: Writing SQL Queries using Oracle for the following database systems
Sl no. Name
1 Insurance Database
2 Banking Enterprise Database
3 Supplier Database
4 Student Faculty Database
5 Airline Flight Database
Part A:
Part A: Front-end development using Visual C#
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
Focus of Visual C# is only on learning to develop front-end i.e., form design using the toolbox.
Students will learn the basic coding to handle events.
Program 1: 1a. Adding two numbers 1b. Finding Largest of three numbers
Introduction
Step1: To create project in Visual Studio 10
Open Visual Studio 2010 - > Click on NewProject - > Visual C# Windows Forms Application ->
Type project name & OK
Program 1:
1a: Adding two numbers
Drag drop required fields into the form - > Properties change the name of the controls (eg.
Textbox1 to Txt_Name)
Double click on Add button to open the code window and then type the code given below given
in the button_click function:
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Lab_prog1
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
Output:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Lab_prog1
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
Output:
Part B: Program 2
2a.Student USN validation
CODE:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace Lab_prog1
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
{
Regex MY_EXP = newRegex("^1BM13CS\\d{3}$");
Match nmat = MY_EXP.Match(Txt_USN.Text);
if (nmat.Success)
{
lbl_Result.Text = "Valid USN";
}
else
{
lbl_Result.Text = "Invalid USN";
}
}
}
}
OUTPUT:
Part B: Program 2
2b. Collect Student Information (USN, Name, Department Name(Combo Box) and Semester
(Radio Button) Using Form And Display it on Message Box
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace Lab_prog1
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
elseif(rbtn_sem4.Checked == true )
msg = "Sem: 4";
MessageBox.Show("USN: " + Txt_USN.Text + " " + "Dept: " + cmb_dept.Text + " " + msg);
}
}
Output:
Part B: Program 3
3. Reading data from already existing database table and displaying it using form grid. Note:
Database table should contain Student name, USN, Department name and Semester.
Server name : BMSCE user name:scott pass: tiger and then click on test connection to check
the connectivity once success click on OK
Left panel - > view the data connection and browse the tables…
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication3
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
connection.Open();
dataadapter.Fill(ds, "stud");
connection.Close();
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "stud";
}
}
}
Output:
Part B: Program 4
4. Insert the new record into the existing database table by accepting the new record information
through form and Update any of the existing database record. Note: Database table should
contain Student name, USN, Department name and Semester.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Data.OleDb;
namespace Lab_prog1
{
publicpartialclassFrm1 : Form
{
OleDbConnection connection;
OleDbDataAdapter dataadapter;
DataSet ds;
publicvoid ConnectString()
{
string connetionString = "Provider=OraOLEDB.Oracle;Data Source=BMSCE;User Id=scott;Password=tiger;";
string sql = "SELECT * FROM stude_info";
OleDbConnection connection = newOleDbConnection(connetionString);
OleDbDataAdapter dataadapter = newOleDbDataAdapter(sql, connection);
ds = newDataSet();
connection.Open();
dataadapter.Fill(ds, "stude_info");
connection.Close();
}
public Frm1()
{
InitializeComponent();
}
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
string sql1 = "Insert into stude_info VALUES ('" + Txt_USN.Text +"', '"+ Txt_name.Text +"', '"+cmb_dept.Text+"', '"+
sem +"' )";
dataadapter.InsertCommand = newOleDbCommand(sql1, connection);
dataadapter.InsertCommand.ExecuteNonQuery();
MessageBox.Show("Row(s) Inserted !! ");
dataadapter.Fill(ds, "stude_info");
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "stude_info";
dataGridView1.Refresh();
connection.Close();
}
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "stude_info";
}
}
Output:
Part B: Program 5
5. Delete the existing record from the database table against USN by accepting it through the
form text box and Search the student database records.
SQL Queries
create table student (usn varchar(10),name varchar(30),dept varchar(5),sem integer));
insert into student values('1BM14CS001','Avinash','CSE',4);
insert into student values('1BM14CS002','Balaji','ISE',4);
insert into student values('1BM14CS003','Chandan','CSE',4);
commit;
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication1
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
dataadapter.Fill(dt);
dataGridView1.DataSource = dt;
connection.Close();
}
if (dt.Rows[0][0].ToString() == "1")
{
MessageBox.Show("Record Found");
}
else
{
MessageBox.Show("Record Not Found");
}
connection.Close();
string sql_search = "select count(*) from student where usn='" + textBox2.Text + "'";
OleDbDataAdapter dataadapter = newOleDbDataAdapter(sql_search, connection);
DataTable dt = newDataTable();
dataadapter.Fill(dt);
if (dt.Rows[0][0].ToString() != "1")
{
MessageBox.Show("Record Not Found");
}
else
{
string sql_delete ="delete from student where usn='"+textBox2.Text+"'";
OleDbCommand cmd = newOleDbCommand(sql_delete, connection);
cmd.ExecuteNonQuery();
MessageBox.Show("Record Deleted");
}
connection.Close();
}
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
}
}
Part B:
INTRODUCTION
3. Click on OK
Consider the Insurance database given below. The data types are specified.
i) Create the above tables by properly specifying the primary keys and the foreign keys.
ii)Enter at least five tuples for each relation.
iii)Demonstrate how you
a.Update the damage amount to 25000 for the car with a specific reg-num(example 'K
A053408') for which the accident report number was 12.
b.Add a new accident to the database.
iv)Find the total number of people who owned cars that involved in accidents in 2008.
v)Find the number of accidents in which cars belonging to a specific model (example )were
involved.
Schema diagram
Tables
QUERY 1: Create the above tables by properly specifying the primary keys and the foreign
keys.
SQL>create table person (driver_id varchar(10),
name varchar(20),
address varchar(30),
primary key(driver_id));
Table created.
SQL>desc person
Name Null? Type
------------------------ -------- ------------------------------
DRIVER_ID NOT NULLVARCHAR2(10)
NAME VARCHAR2(20)
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
ADDRESSVARCHAR2(30)
SQL>desc car
Name Null? Type
------------------------ -------- ----------------------------------
REG_NUM NOT NULLVARCHAR2(10)
MODEL VARCHAR2(10)
YEAR NUMBER(38)
Table created.
SQL>desc accident
Name Null? Type
-------------------------- -------- ----------------------------
REPORT_NUM NOT NULL NUMBER(38)
ACCIDENT_DATE DATE
LOCATION VARCHAR2(20)
Table created.
SQL>desc owns
Name Null? Type
------------------------------- -------- --------------------------------
DRIVER_ID NOT NULL VARCHAR2(10)
REG_NUM NOT NULL VARCHAR2(10)
1 row created.
SQL>/
Enter value for driver_id: A02
Enter value for name: Pradeep
Enter value for address: Rajajinagar
old 1: insert into person values('&driver_id','&name','&address')
new 1: insert into person values('A02','Pradeep','Rajajinagar')
1 row created.
SQL>commit;
Commit complete.
1 row created.
SQL>/
Enter value for reg_num: KA031181
Enter value for model: Lancer
Enter value for year: 1957
old 1: insert into car values('®_num','&model',&year)
new 1: insert into car values('KA031181','Lancer', 1957)
1 row created.
SQL>commit;
Commit complete.
1 row created.
SQL>commit;
Commit complete.
SQL> select * from accident;
SQL>commit;
Commit complete.
DRIVER_ID REG_NUM
---------------- ----------
A01 KA052250
A02 KA053408
A04 KA031181
A03 KA095477
A05 KA041702
SQL> insert into participated values ('&driver_id','®_num',&report_num,
&damage_amount);
1 row created.
SQL>/
Enter value for driver_id: A02
Enter value for reg_num: KA053408
Enter value for report_num: 12
Enter value for damage_amount: 50000
old 1: insert into participated values ('&driver_id','®_num', &report_num,&
damage_amount)
new 1: insert into participated values('A02','KA053408',12,50000)
1 row created.
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
SQL>commit;
Commit complete.
SQL> select * from participated;
QUERY 3:
a) Update the damage amount to 25000 for the car with a specific reg_num (example 'K
A053408' ) for which the accident report number was 12.
1 row updated.
SQL>commit;
Commit complete.
REPORT_NUMACCIDENT_DATE LOCATION
------------------ ------------ --------------------
11 01-JAN-03 Mysore Road
12 02-FEB-04 Southend Circle
13 21-JAN-03 Bulltemple Road
14 17-FEB-08 Mysore Road
15 04-MAR-05 Kanakpura Road
16 15-MAR-08 Domlur
6 rows selected.
QUERY 4: Find the total number of people who owned cars that were involved in
accidents in 2008.
CNT
----------
1
QUERY 5: Find the number of accidents in which cars belonging to a specific model (example
'Lancer') were involved.
SQL> select count(report_num) CNT from car c,participated p where c.reg_num=p.reg_num and
model='Lancer';
CNT
----------
1
ADDITIONAL QUERIES:
1) LIST THE ENTIRE PARTICIPATED RELATION IN THE DESCENDING ORDER
OF DAMAGE AMOUNT.
SQL> SELECT * FROM PARTICIPATED ORDER BY DAMAGE_AMOUNTT DESC;
i. Create the above tables by properly specifying the primary keys and the
foreign keys.
ii. Enter at least five tuples for each relation.
iii. Find all the customers who have at least two accounts at the Main branch (ex.
SBI_ResidencyRoad).
iv. Find all the customers who have an account at all the branches located in a
specific city (Ex. Delhi).
v. Demonstrate how you delete all account tuples at every branch located in
a specific city (Ex. Bombay).
INTRODUCTION: This database is developed for supporting banking facilities. Details of the
branch along with the accounts and loans handled by them are recorded. Also details of the
depositors of the corresponding branches are maintained.
Schema Diagram
Sample Table data
QUERY 1: Create the above tables by properly specifying the primary keys and the foreign
keys.
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
QUERY 2: Enter at least five tuples for each relation
Commit complete.
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
QUERY 3: Find Find all the customers who have at least two deposits at
the same branch (Ex. ‘SBI_ResidencyRoad’).
QUERY 4: Find all the customers who have an account at all the
branches located in a specific city (Ex. Delhi).
QUERY 5: Demonstrate how you delete all account tuples at every branch located in a
specific city (Ex. Bomay).
ADDITIONAL QUERIES:
1. LIST THE ENTIRE LOAN RELATION IN THE DESCENDING ORDER OF
AMOUNT.
SQL> SELECT * FROM LOAN ORDER BY AMOUNT DESC;
2. FIND ALL CUSTOMERS HAVING A LAON, AN ACCOUNT OR BOTH AT THE
BANK
SQL> (SELECT CUSTOMER_NAME FROM DEPOSITOR ) UNION (SELECT CUSTOMER_NAME FROM
BORROWER);
3. CREATE A VIEW WHICH GIVES EACH BRANCH THE SUM OF THE AMOUNT
OF ALL THE LOANS AT THE BRANCH.
SQL> CREATE VIEW BRANCH_TOTAL_LOAN (BRANCH_NAME, TOTAL_LOAN) AS SELECT
BRANCH_NAME, SUM(AMOUNT) FROM LOAN GROUP BY BRANCH_NAME;
4. THE ANNUAL INTEREST PAYMENTS ARE MADE AND ALL BRANCHES ARE
TO BE INCREASED BY 5%.
SQL> UPDATE ACCOUNT SET BALANCE=BALANCE *1.05;
iv) Find the pnames of parts supplied by Acme Widget Suppliers and by no one else.
v) Find the sids of suppliers who charge more for some part than the average cost of that
part (averaged over all the suppliers who supply that part).
vi) For each part, find the sname of the supplier who charges the most for that part.
Schema Diagram
Table Data
CREATION of Tables:
SQL> create table SUPPLIERS(sid number(5) primary key, sname varchar(20), city varchar(20));
Table created.
SQL> create table PARTS(pid number(5) primary key, pname varchar(20), color varchar(10));
Table created.
Table created.
INSERTION OF DATA:
1 row created.
SQL> /
Enter value for sid: 10002
Enter value for sname: Johns
Enter value for address: Kolkata
old 1: insert into suppliers values(&sid, '&sname','&city')
new 1: insert into suppliers values(10002, 'Johns','Kolkata')
1 row created.
SQL> /
Enter value for sid: 10003
Enter value for sname: Vimal
Enter value for address: Mumbai
old 1: insert into suppliers values(&sid, '&sname','&city')
new 1: insert into suppliers values(10003, 'Vimal','Mumbai')
1 row created.
SQL> /
Enter value for sid: 10004
Enter value for sname: Reliance
Enter value for address: Delhi
old 1: insert into suppliers values(&sid, '&sname','&city')
new 1: insert into suppliers values(10004, 'Reliance','Delhi')
1 row created.
SQL> /
Enter value for sid: 10005
Enter value for sname: Mahindra
Enter value for address: Mumbai
old 1: insert into suppliers values(&sid, '&sname','&city')
new 1: insert into suppliers values(10005, 'Mahindra','Mumbai')
1 row created.
SQL> commit;
Commit complete.
1 row created.
SQL> /
Enter value for pid: 20002
Enter value for pname: Pen
Enter value for color: Red
old 1: insert into PARTS values(&pid, '&pname','&color')
new 1: insert into PARTS values(20002, 'Pen','Red')
1 row created.
SQL> /
Enter value for pid: 20003
Enter value for pname: Pencil
Enter value for color: Green
old 1: insert into PARTS values(&pid, '&pname','&color')
new 1: insert into PARTS values(20003, 'Pencil','Green')
1 row created.
SQL> /
Enter value for pid: 20004
Enter value for pname: Mobile
Enter value for color: Green
old 1: insert into PARTS values(&pid, '&pname','&color')
new 1: insert into PARTS values(20004, 'Mobile','Green')
1 row created.
SQL> /
Enter value for pid: 20005
Enter value for pname: Charger
Enter value for color: Black
old 1: insert into PARTS values(&pid, '&pname','&color')
new 1: insert into PARTS values(20005, 'Charger','Black')
1 row created.
SQL> commit;
Commit complete.
1 row created.
SQL> /
Enter value for sid: 10001
Enter value for pid: 20002
Enter value for cost: 10
old 1: insert into CATALOG values(&sid, '&pid','&cost')
new 1: insert into CATALOG values(10001, '20002','10')
1 row created.
SQL> /
Enter value for sid: 10001
Enter value for pid: 20003
Enter value for cost: 30
old 1: insert into CATALOG values(&sid, '&pid','&cost')
new 1: insert into CATALOG values(10001, '20003','30')
1 row created.
SQL> /
Enter value for sid: 10001
Enter value for pid: 20004
Enter value for cost: 10
old 1: insert into CATALOG values(&sid, '&pid','&cost')
new 1: insert into CATALOG values(10001, '20004','10')
1 row created.
SQL> /
Enter value for sid: 10001
Enter value for pid: 20005
Enter value for cost: 10
old 1: insert into CATALOG values(&sid, '&pid','&cost')
new 1: insert into CATALOG values(10001, '20005','10')
1 row created.
SQL> /
Enter value for sid: 10002
Enter value for pid: 20001
Enter value for cost: 10
old 1: insert into CATALOG values(&sid, '&pid','&cost')
new 1: insert into CATALOG values(10002, '20001','10')
1 row created.
SQL> /
Enter value for sid: 10002
Enter value for pid: 20002
Enter value for cost: 20
old 1: insert into CATALOG values(&sid, '&pid','&cost')
new 1: insert into CATALOG values(10002, '20002','20')
1 row created.
SQL> /
Enter value for sid: 10003
Enter value for pid: 20003
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
1 row created.
SQL> /
Enter value for sid: 10004
Enter value for pid: 20003
Enter value for cost: 40
old 1: insert into CATALOG values(&sid, '&pid','&cost')
new 1: insert into CATALOG values(10004, '20003','40')
1 row created.
9 rows selected.
i) Find the pnames of parts for which there is some supplier.
PNAME
--------------------
Book
Charger
Mobile
Pen
Pencil
SNAME
--------------------
Acme Widget
iii) Find the snames of suppliers who supply every red part.
SQL>SELECT S.sname
FROM Suppliers S
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
iv) Find the pnames of parts supplied by Acme Widget Suppliers and by no one else.
PNAME
--------------------
Mobile
Charger
v) Find the sids of suppliers who charge more for some part than the average cost of
that part (averaged over all the suppliers who supply that part).
PID SNAME
---------- --------------------
20001 Acme Widget
20004 Acme Widget
20005 Acme Widget
20001 Johns
20002 Johns
20003 Reliance
6 rows selected.
iii. Find the names of all students who are enrolled in two classes that meet at the same
time.
iv. Find the names of faculty members who teach in every room in which some class is
taught.
v. Find the names of faculty members for whom the combined enrollment of the courses
that they teach is less than five.
vi. Find the names of students who are not enrolled in any class.
vii. For each age value that appears in Students, find the level value that appears most
often. For example, if there are more FR level students aged 18 than SR, JR, or SO
students aged 18, you should print the pair (18, FR).
Table created.
Table created.
Table created.
Table created.
SQL> commit;
Commit complete.
INSERTION OF VALUES:
1 row created.
SQL> /
Enter value for snum: 2
Enter value for sname: Smith
Enter value for major: CS
Enter value for lvl: Jr
Enter value for age: 20
old 1: INSERT INTO STUDENT VALUES(&snum, '&sname', '&major', '&lvl', &age)
new 1: INSERT INTO STUDENT VALUES(2, 'Smith', 'CS', 'Jr', 20)
1 row created.
SQL> /
Enter value for snum: 3
Enter value for sname: Jacob
Enter value for major: CV
Enter value for lvl: Sr
Enter value for age: 20
old 1: INSERT INTO STUDENT VALUES(&snum, '&sname', '&major', '&lvl', &age)
new 1: INSERT INTO STUDENT VALUES(3 , 'Jacob', 'CV', 'Sr', 20)
1 row created.
SQL> /
Enter value for snum: 4
Enter value for sname: Tom
Enter value for major: CS
Enter value for lvl: Jr
Enter value for age: 20
old 1: INSERT INTO STUDENT VALUES(&snum, '&sname', '&major', '&lvl', &age)
new 1: INSERT INTO STUDENT VALUES(4, 'Tom ', 'CS', 'Jr', 20)
1 row created.
SQL> /
Enter value for snum: 5
Enter value for sname: Rahul
Enter value for major: CS
Enter value for lvl: Jr
Enter value for age: 20
old 1: INSERT INTO STUDENT VALUES(&snum, '&sname', '&major', '&lvl', &age)
new 1: INSERT INTO STUDENT VALUES(5, 'Rahul', 'CS', 'Jr', 20)
1 row created.
SQL> /
Enter value for snum: 6
Enter value for sname: Rita
Enter value for major: CS
Enter value for lvl: Sr
Enter value for age: 21
old 1: INSERT INTO STUDENT VALUES(&snum, '&sname', '&major', '&lvl', &age)
new 1: INSERT INTO STUDENT VALUES(6, 'Rita', 'CS', 'Sr', 21)
1 row created.
6 rows selected.
1 row created.
SQL> /
Enter value for fid: 12
Enter value for fname: MV
Enter value for deptid: 1000
old 1: INSERT INTO FACULTY VALUES(&FID, '&FNAME', &DEPTID)
new 1: INSERT INTO FACULTY VALUES(12, 'MV', 1000)
1 row created.
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
SQL> /
Enter value for fid: 13
Enter value for fname: Mira
Enter value for deptid: 1001
old 1: INSERT INTO FACULTY VALUES(&FID, '&FNAME', &DEPTID)
new 1: INSERT INTO FACULTY VALUES(13 , 'Mira', 1001)
1 row created.
SQL> /
Enter value for fid: 14
Enter value for fname: Shiva
Enter value for deptid: 1002
old 1: INSERT INTO FACULTY VALUES(&FID, '&FNAME', &DEPTID)
new 1: INSERT INTO FACULTY VALUES(14, 'Shiva', 1002)
1 row created.
SQL> /
Enter value for fid: 15
Enter value for fname: Nupur
Enter value for deptid: 1000
old 1: INSERT INTO FACULTY VALUES(&FID, '&FNAME', &DEPTID)
new 1: INSERT INTO FACULTY VALUES(15, 'Nupur', 1000)
1 row created.
SQL> commit;
Commit complete.
SQL> commit;
Commit complete.
SQL> alter session set nls_timestamp_format = 'RR/MM/DD HH24:MI:SSXFF';
Session altered.
Session altered.
1 row created.
1 row created.
SQL> /
Enter value for cname: class2
Enter value for meets_at: 12/11/15 10:15:20
Enter value for room: R2
Enter value for fid: 12
old 1: insert into class values('&cname', '&meets_at', '&room', &fid)
new 1: insert into class values('class2', '12/11/15 10:15:20', 'R2', 12)
1 row created.
1 row created.
SQL> /
Enter value for cname: class4
Enter value for meets_at: 12/11/15 20:15:20
Enter value for room: R4
Enter value for fid: 14
old 1: insert into class values('&cname', '&meets_at', '&room', &fid)
new 1: insert into class values('class4', '12/11/15 20:15:20', 'R4', 14)
1 row created.
SQL> /
Enter value for cname: class5
Enter value for meets_at: 12/11/15 20:15:20
Enter value for room: R3
Enter value for fid: 15
old 1: insert into class values('&cname', '&meets_at', '&room', &fid)
new 1: insert into class values('class5', '12/11/15 20:15:20', 'R3', 15)
1 row created.
SQL> /
Enter value for cname: class6
Enter value for meets_at: 12/11/15 13:20:20
Enter value for room: R2
Enter value for fid: 14
old 1: insert into class values('&cname', '&meets_at', '&room', &fid)
new 1: insert into class values('class6', '12/11/15 13:20:20', 'R2', 14)
1 row created.
SQL> /
Enter value for cname: class7
Enter value for meets_at: 12/11/15 10:10:10
Enter value for room: R3
Enter value for fid: 14
old 1: insert into class values('&cname', '&meets_at', '&room', &fid)
new 1: insert into class values('class7', '12/11/15 10:10:10', 'R3', 14)
1 row created.
CNAME
--------------------
METTS_AT
---------------------------------------------------------------------------
ROOM FID
---------- ----------
class1
12/11/15 10:15:16.000000
R1 14
class10
12/11/15 10:15:16.000000
R128 14
CNAME
--------------------
METTS_AT
---------------------------------------------------------------------------
ROOM FID
---------- ----------
class2
12/11/15 10:15:20.000000
R2 12
class3
12/11/15 10:15:25.000000
CNAME
--------------------
METTS_AT
---------------------------------------------------------------------------
ROOM FID
---------- ----------
R3 11
class4
12/11/15 20:15:20.000000
R4 14
class5
CNAME
--------------------
METTS_AT
---------------------------------------------------------------------------
ROOM FID
---------- ----------
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
12/11/15 20:15:20.000000
R3 15
class6
12/11/15 13:20:20.000000
R2 14
CNAME
--------------------
METTS_AT
---------------------------------------------------------------------------
ROOM FID
---------- ----------
class7
12/11/15 10:10:10.000000
R3 14
8 rows selected.
SQL> commit;
Commit complete.
1 row created.
SQL> /
Enter value for snum: 2
Enter value for cname: class1
old 1: insert into enrolled values(&snum, '&cname')
new 1: insert into enrolled values(2, 'class1')
1 row created.
SQL> /
Enter value for snum: 3
Enter value for cname: class3
old 1: insert into enrolled values(&snum, '&cname')
new 1: insert into enrolled values(3, 'class3')
1 row created.
SQL> /
Enter value for snum: 4
Enter value for cname: class3
old 1: insert into enrolled values(&snum, '&cname')
new 1: insert into enrolled values(4, 'class3')
1 row created.
SQL> /
Enter value for snum: 5
Enter value for cname: class4
old 1: insert into enrolled values(&snum, '&cname')
new 1: insert into enrolled values(5, 'class4')
1 row created.
SQL> /
Enter value for snum: 1
Enter value for cname: class5
old 1: insert into enrolled values(&snum, '&cname')
new 1: insert into enrolled values(1, 'class5')
1 row created.
SQL> /
Enter value for snum: 2
Enter value for cname: class5
old 1: insert into enrolled values(&snum, '&cname')
new 1: insert into enrolled values(2, 'class5')
1 row created.
SQL> /
Enter value for snum: 3
Enter value for cname: class5
old 1: insert into enrolled values(&snum, '&cname')
new 1: insert into enrolled values(3, 'class5')
1 row created.
SQL> /
Enter value for snum: 4
Enter value for cname: class5
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
1 row created.
SQL> /
Enter value for snum: 5
Enter value for cname: class5
old 1: insert into enrolled values(&snum, '&cname')
new 1: insert into enrolled values(5, 'class5')
1 row created.
SNUM CNAME
---------- --------------------
1 class1
2 class1
3 class3
4 class3
5 class4
1 class5
2 class5
3 class5
4 class5
5 class5
10 rows selected.
viii. Find the names of all Juniors (level(lvl) = Jr) who are enrolled in a class taught
by Harish.
SNAME
----------
Tom
ix. Find the names of all classes that either meet in room R128 or have five or more
Students enrolled.
SQL>SELECT C.cname
FROM Class C
WHERE C.room = ‘R128’
OR C.cname IN (SELECT E.cname
FROM Enrolled E
GROUP BY E.cname
HAVING COUNT (*) >= 5);
CNAME
--------------------
class10
class5
x. Find the names of all students who are enrolled in two classes that meet at the same
time.
SQL>SELECT DISTINCT S.sname
FROM Student S
WHERE S.snum IN (SELECT E1.snum
FROM Enrolled E1, Enrolled E2, Class C1, Class C2
WHERE E1.snum = E2.snum AND E1.cname <> E2.cname
AND E1.cname = C1.cname
AND E2.cname = C2.cname AND C1.meets_at = C2.meets_at);
SNAME
----------
Rahul
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
xi. Find the names of faculty members who teach in every room in which some class
is taught.
FNAME
--------------------
Shiva
xii. Find the names of faculty members for whom the combined enrollment of the
courses that they teach is less than five.
SQL>SELECT DISTINCT F.fname
FROM Faculty F
WHERE 5 > (SELECT COUNT (E.snum)
FROM Class C, Enrolled E
WHERE C.cname = E.cname
AND C.fid = F.fid)
FNAME
--------------------
Harish
MV
Mira
Shiva
xiii. Find the names of students who are not enrolled in any class.
SNAME
----------
Rita
xiv. For each age value that appears in Students, find the level value that appears
most often. For example, if there are more FR level students aged 18 than SR,
JR, or SO students aged 18, you should print the pair (18, FR).
AGE LV
---------- --
19 Sr
20 Jr
21 Sr
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
Consider the following database that keeps track of airline flight information:
FLIGHTS(flno: integer, from: string, to: string, distance: integer, departs: time, arrives:
time, price: integer)
AIRCRAFT(aid: integer, aname: string, cruisingrange: integer)
CERTIFIED(eid: integer, aid: integer)
EMPLOYEES(eid: integer, ename: string, salary: integer)
Note that the Employees relation describes pilots and other kinds of employees as well;
Every pilot is certified for some aircraft, and only pilots are certified to fly.
Write each of the following queries in SQL.
i. Find the names of aircraft such that all pilots certified to operate them have salaries
more than Rs.80,000.
ii. For each pilot who is certified for more than three aircrafts, find the eid and the
maximum cruisingrange of the aircraft for which she or he is certified.
iii. Find the names of pilots whose salary is less than the price of the cheapest route from
Bengaluru to Frankfurt.
iv. For all aircraft with cruisingrange over 1000 Kms, find the name of the aircraft and
the average salary of all pilots certified for this aircraft.
v. Find the names of pilots certified for some Boeing aircraft.
vi. Find the aids of all aircraft that can be used on routes from Bengaluru to New Delhi.
vii. A customer wants to travel from Madison to New York with no more than two
changes of flight. List the choice of departure times from Madison if the customer
wants to arrive in New York by 6 p.m.
CREATION OF TABLES:
Table created.
Table created.
Table created.
Table created.
SQL> COMMIT;
Commit complete.
INSERTION OF VALUES:
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
SQL> insert into aircraft values(107,'Dream', 120000);
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
SQL> alter session set nls_timestamp_format = 'RR/MM/DD HH24:MI:SSXFF';
Session altered.
Session altered.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
---------------------------------------------------------------------------
ARRIVES
---------------------------------------------------------------------------
PRICE
----------
101 Bangalore Delhi 2500
13-MAY-05 07.15.31.000000 AM
13-MAY-05 07.15.31.000000 AM
5000
6 rows selected.
7 rows selected.
EID AID
---------- ----------
701 101
701 102
701 106
701 105
702 104
703 104
704 104
702 107
703 107
704 107
702 101
EID AID
---------- ----------
703 105
704 105
705 103
14 rows selected.
7 rows selected.
viii. Find the names of aircraft such that all pilots certified to operate them have
salaries more than Rs.80,000.
ANAME
----------
747
Boeing
Dream
Dreamliner
ix. For each pilot who is certified for more than three aircrafts, find the eid and the
maximum cruising range of the aircraft for which she or he is certified.
GROUP BY C.eid
HAVING COUNT (*) > 3;
EID MAX(A.CRUISINGRANGE)
---------- --------------------
701 3500
x. Find the names of pilots whose salary is less than the price of the cheapest route
from Bangalore to Frankfurt.
ENAME
---------------
A
E
xi. For all aircraft with cruising range over 1000 Kms, find the name of the aircraft
and the average salary of all pilots certified for this aircraft.
NAME AVGSALARY
---------- ----------
747 75000
Dreamliner 113333.333
Boeing 96666.6667
707 50000
Dream 113333.333
xii. Find the names of pilots certified for some Boeing aircraft.
xiii. Find the aids of all aircraft that can be used on routes from Bangalore to
Frankfurt.
SELECT A.aid
FROM Aircraft A
WHERE A.cruisingrange >( SELECT MIN (F.distance)
FROM Flights F
WHERE F.ffrom = ‘Bangalore’ AND F.tto = ‘Frankfurt’ );
AID
----------
104
107
xiv. A customer wants to travel from Bangalore to Delhi with no more than two
changes of flight. List the choice of departure times from Bangalore if the
customer wants to arrive in Delhi by 6 p.m.
SELECT F.departs
FROM Flights F
WHERE F.flno IN ( ( SELECT F0.flno
FROM Flights F0
WHERE F0.ffrom = ‘Bangalore’ AND F0.tto = ‘Delhi’
AND extract(hour from F0.arrives) < 18 )
UNION
( SELECT F0.flno
FROM Flights F0, Flights F1
WHERE F0.ffrom = ‘Bangalore’ AND F0.tto <> ‘Delhi’
AND F0.tto = F1.ffrom AND F1.tto = ‘Delhi’
AND F1.departs > F0.arrives
AND extract(hour from F1.arrives) < 18)
UNION
( SELECT F0.flno
FROM Flights F0, Flights F1, Flights F2
WHERE F0.ffrom = ‘Bangalore’
AND F0.tto = F1.ffrom
AND F1.tto = F2.ffrom
AND F2.tto = ‘Delhi’
AND F0.tto <> ‘Delhi’
AND F1.tto <> ‘Delhi’
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
DEPARTS
---------------------------------------------------------------------------
05/05/13 07:15:31.000000
05/05/13 07:15:31.000000
xv. Print the name and salary of every non-pilot whose salary is more than the
average salary for pilots.
ENAME SALARY
--------------- ----------
G 90000
rt C: Practise Questions
SQL-QUERIES
13. List the emps along with their Exp and Daily Sal is more than Rs.100.
14. List the emps who are either ‘CLERK’ or ‘ANALYST’ in the Desc order.
15. List the emps who joined on 1-MAY-81,3-DEC-81,17-DEC-81,19-JAN-80 in asc order
of seniority.
16. List the emp who are working for the Deptno 10 or20.
17. List the emps who are joined in the year 81.
18. List the emps who are joined in the month of Aug 1980.
19. List the emps Who Annual sal ranging from 22000 and 45000.
20. List the Enames those are having five characters in their Names.
21. List the Enames those are starting with ‘S’ and with five characters.
22. List the emps those are having four chars and third character must be ‘r’.
23. List the Five character names starting with ‘S’ and ending with ‘H’.
24. List the emps who joined in January.
25. List the emps who joined in the month of which second character is ‘a’.
26. List the emps whose Sal is four digit number ending with Zero.
27. List the emps whose names having a character set ‘ll’ together.
29. List the emps who does not belong to Deptno 20.
30. List all the emps except ‘PRESIDENT’ & ‘MGR” in asc order of Salaries.
31. List all the emps who joined before or after 1981.
32. List the emps whose Empno not starting with digit78.
33. List the emps who are working under ‘MGR’.
34. List the emps who joined in any year but not belongs to the month of March.
35. List all the Clerks of Deptno 20.
36. List the emps of Deptno 30 or 10 joined in the year 1981.
37. Display the details of SMITH.
38. Display the location of SMITH.
39. List the total information of EMP table along with DNAME and Loc of all the emps
Working Under ‘ACCOUNTING’ & ‘RESEARCH’ in the asc Deptno.
40. List the Empno, Ename, Sal, Dname of all the ‘MGRS’ and ‘ANALYST’ working in
New York, Dallas with an exp more than 7 years without receiving the Comm asc order of Loc.
41. Display the Empno, Ename, Sal, Dname, Loc, Deptno, Job of all emps working at
CJICAGO or working for ACCOUNTING dept with Ann Sal>28000, but the Sal should not
be=3000 or 2800 who doesn’t belongs to the Mgr and whose no is having a digit ‘7’ or ‘8’ in 3rd
position in the asc order of Deptno and desc order of job.
42. Display the total information of the emps along with Grades in the asc order.
45. List the Empno, Ename, Sal, Dname, Grade, Exp, and Ann Sal of emps working for
Dept10 or20.
46. List all the information of emp with Loc and the Grade of all the emps belong to the
Grade range from 2 to 4 working at the Dept those are not starting with char set ‘OP’ and not
ending with ‘S’ with the designation having a char ‘a’ any where joined in the year 1981 but not
in the month of Mar or Sep and Sal not end with ‘00’ in the asc order of Grades
47. List the details of the Depts along with Empno, Ename or without the emps
48. List the details of the emps whose Salaries more than the employee BLAKE.
49. List the emps whose Jobs are same as ALLEN.
50. List the emps who are senior to King.
51. List the Emps who are senior to their own MGRS.
52. List the Emps of Deptno 20 whose Jobs are same as Deptno10.
53. List the Emps whose Sal is same as FORD or SMITH in desc order of Sal.
54. List the emps Whose Jobs are same as MILLER or Sal is more than ALLEN.
55. List the Emps whose Sal is > the total remuneration of the SALESMAN.
56. List the emps who are senior to BLAKE working at CHICAGO & BOSTON.
57. List the Emps of Grade 3,4 belongs to the dept ACCOUNTING and RESEARCH whose
Sal is more than ALLEN and exp more than SMITH in the asc order of EXP.
59. Write a Query to display the details of emps whose Sal is same as of
60. Any jobs of deptno 10 those that are not found in deptno 20.
66. List the employees who are senior to most recently hired employee working under king.
67. List the details of the employee belongs to newyork with grade 3 to 5 except
‘PRESIDENT’ whose sal> the highest paid employee of Chicago in a group where there is
manager and salesman not working under king
69. List the employees who joined in 1981 with the job same as the most senior person of the
year 1981.
70. List the most senior empl working under the king and grade is more than 3.
72. Find the total annual sal to distribute job wise in the year 81.
75. List the employeein dept 20 whose sal is >the average sal 0f dept 10 emps.
76. Display the number of employee for each job group deptno wise.
77. List the manage rno and the number of employees working for those mgrs in the
ascending Mgrno.
78. List the department,details where at least two emps are working
79. Display the Grade, Number of emps, and max sal of each grade.
80. Display dname, grade, No. of emps where at least two emps are clerks.
81. List the details of the department where maximum number of emps are working.
85. List the emps who are not working in sales dept.
86. List the emps name ,dept, sal and comm. For those whose salary is between 2000 and
5000 while loc is Chicago.
87. List the emps whose sal is greater than his managers salary
88. List the grade, EMP name for the deptno 10 or deptno 30 but sal grade is not 4 while they
joined the company before ’31-dec-82’.
89. List the name ,job, dname, location for those who are working as MGRS.
90. List the emps whose mgr name is jones and also list their manager name.
91. List the name and salary of ford if his salary is equal to hisal of his grade.
92. Lit the name, job, dname ,sal, grade dept wise
93. List the emp name, job, sal, grade and dname except clerks and sort on the basis of
highest sal.
94. List the emps name, job who are with out manager.
95. List the names of the emps who are getting the highest sal dept wise.
96. List the emps whose sal is equal to the average of max and minimum
97. List the no. of emps in each department where the no. is more than 3.
98. List the names of depts. Where atleast 3 are working in that department.
99. List the managers whose sal is more than his employess avg salary.
100. List the name,salary,comm. For those employees whose net pay is greater than or equal
to any other employee salary of the company.
101. List the emp whose sal<his manager but more than any other manager.
102. List the employee names and his average salary department wise.
104. Find out emps whose salaries greater than salaries of their managers.
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
105. List the managers who are not working under the president.
106. List the records from emp whose deptno isnot in dept.
107. List the Name , Salary, Comm and Net Pay is more than any other employee.
108. List the Enames who are retiring after 31-Dec-89 the max Job period is 20Y.
114. List the emps whose first 2 chars from Hiredate=last 2 characters of Salary.
115. List the emps Whose 10% of Salary is equal to year of joining.
116. List first 50% of chars of Ename in Lower Case and remaining are upper Case.
117. List the Dname whose No. of Emps is =to number of chars in the Dname.
118. List the emps those who joined in company before 15th of the month.
119. List the Dname, no of chars of which is = no. of emp’s in any other Dept.
121. List THE Name of dept where highest no.of emps are working.
122. Count the No.of emps who are working as ‘Managers’(using set option).
123. List the emps who joined in the company on the same date.
124. List the details of the emps whose Grade is equal to one tenth of Sales Dept.
125. List the name of the dept where more than average no. of emps are working.
126. List the Managers name who is having max no.of emps working under him.
127. List the Ename and Sal is increased by 15% and expressed as no.of Dollars.
128. Produce the output of EMP table ‘EMP_AND_JOB’ for Ename and Job.
130) List the emps with Hire date in format June 4, 1988.
131) Print a list of emp’s Listing ‘just salary’ if Salary is more than 1500, on target if Salary is
1500 and ‘Below 1500’ if Salary is less than 1500.
132) Write a query which return the day of the week for any date entered in format ‘DD-MM-
YY’.
133) Write a query to calculate the length of service of any employee with the company, use
DEFINE to avoid repetitive typing of functions.
134) Give a string of format ‘NN/NN’, verify that the first and last two characters are numbers
and that the middle character is’/’. Print the expression ‘YES’ if valid, ‘NO’ if not valid. Use the
following values to test your solution. ‘12/34’,’01/1a’, ‘99/98’.
135) Emps hired on or before 15th of any month are paid on the last Friday of that month those
hired after 15th are paid on the first Friday of the following month. Print a list of emps their hire
date and the first pay date. Sort on hire date.
136) Count the no. of characters with out considering spaces for each name.
137) Find out the emps who are getting decimal value in their Sal without using like operator.
138) List those emps whose Salary contains first four digit of their Deptno.
139) List those Managers who are getting less than his emps Salary.
140) Print the details of all the emps who are sub-ordinates to Blake.
141) List the emps who are working as Managers using co-related sub-query.
142) List the emps whose Mgr name is ‘Jones’ and also with his Manager name.
143) Define a variable representing the expression used to calculate on emps total annual
remuneration use the variable in a statement, which finds all emps who can earn 30000 a year or
more.
144) Find out how may Managers are their in the company.
145) Find Average salary and Average total remuneration for each Job type. Remember
Salesman earn commission.secommm
146) Check whether all the emps numbers are indeed unique.
147) List the emps who are drawing less than 1000 Sort the output by Salary.
148) List the employee Name, Job, Annual Salary, deptno, Dept name and grade who earn
36000 a year or who are not CLERKS.
149) Find out the Job that was filled in the first half of 1983 and same job that was filled
during the same period of 1984.
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
150) Find out the emps who joined in the company before their Managers.
151) List all the emps by name and number along with their Manager’s name and number.
Also List KING who has no ‘Manager’.
152) Find all the emps who earn the minimum Salary for each job wise in ascending order.
153) Find out all the emps who earn highest salary in each job type. Sort in descending salary
order.
154) Find out the most recently hired emps in each Dept order by Hiredate.
155) List the employee name,Salary and Deptno for each employee who earns a salary greater
than the average for their department order by Deptno.
161) List the Deptno, Name, Job, Salary and Sal+Comm of the SALESMAN who are earning
maximum salary and commission in descending order.
162) List the Deptno, Name, Job, Salary and Sal+Comm of the emps who earn the second
highest earnings (sal + comm.).
163) List the Deptno and their average salaries for dept with the average salary less than the
averages for all department
164) List out the Names and Salaries of the emps along with their manager names and salaries
for those emps who earn more salary than their Manager.
165) List out the Name, Job, Salary of the emps in the department with the highest average
salary.
167) List the details of the emps in the ascending order of the sal.
168) List the dept in the ascending order of the job and the desc order of the emps print
empno, ename.
174) List the empno,ename,sal,deptno of the dept 10 emps in the ascending order of salary.
175) List the emps whose salaries are less than 3500.
176) List the empno,ename,sal of all the emp joined before 1 apr 81.
177) List the emp whose annual sal is <25000 in the asc order of the salaries.
178) List the empno,ename,annsal,dailysal of all the salesmen in the asc ann sal
179) List the empno,ename,hiredate,current date & exp in the ascending order of the exp.
184) List the emps who have joined on the following dates 1 may 81,17 nov 81,30 dec 81
185) List the emps who have joined in the year 1981.
186) List the emps whose annual sal ranging from 23000 to 40000.
188) List the emps who joined in the second half of 82.
190) List the emp names starting with ‘M’ with 5 chars.
DATABASE MANAGEMENT SYSTEM LABORATORY MANUAL
191) List the emps end with ‘H’ all together 5 chars.
200) List the emp who are clerks who have exp more than 8ys.
202) List the emps joined in jan with salary ranging from 1500 to 4000.
204) List the emps along with exp of those working under the mgr whose number is starting
with 7 but should not have a 9 joined before 1983.
205) List the emps who are working as either mgr or analyst with the salary ranging from 2000
to 5000 and with out comm.
206) List the empno,ename,sal,job of the emps with /ann sal <34000 but receiving some
comm. Which should not be>sal and desg should be sales man working for dept 30.
207) List the emps who are working for dept 10 or 20 with desgs as clerk or analyst with a sal
is either 3 or 4 digits with an exp>8ys but does not belong to mons of mar,apr,sep and working
for mgrs &no is not ending with 88 and 56.
208) List the empno,ename,sal,job,deptno&exp of all the emps belongs to dept 10 or 20 with
an exp 6 to 10 y working under the same mgr with out comm. With a job not ending irrespective
of the position with comm.>200 with exp>=7y and sal<2500 but not belongs to the month sep or
nov working under the mgr whose no is not having digits either 9 or 0 in the asc dept& desc dept
212) List the empno, ename, sal, loc of the emps working at Chicago dallas with an exp>6ys.
213) List the emps along with loc of those who belongs to dallas ,newyork with sal ranging
from 2000 to 5000 joined in 81.
214) List the empno,ename,sal,grade of all emps.
216) List the emps with loc and grade of accounting dept or the locs dallas or Chicago with the
grades 3 to 5 &exp >6y
217) List the grades 3 emps of research and operations depts..joined after 1987 and whose
names should not be either miller or allen.
220) List the emps whose job is same as either allen or sal>allen.
221) List the emps who are senior to their own manager.
222) List the emps whose sal greater than blakes sal.
224) List the mgrs who are senior to king and who are junior to smith.
225) List the empno,ename,loc,sal,dname,loc of the all the emps belonging to king dept.
226) List the emps whose salgrade are greater than the grade of miller.
227) List the emps who are belonging dallas or Chicago with the grade same as adamsor exp
more than smith.
229) List the emps whose sal is same as any one of the following.
232) The total remuneration (sal+comm.) of all sales person of Sales dept belonging to emp3
table.
236) List the details of most recently hired emp of dept 30.
237) List the highest paid emp of Chicago joined before the most recently hired emp of grade
2.