sql2 PDF
sql2 PDF
sql2 PDF
1 Write a program to implement STACK using array. Perform the following operations on the
STACK:
a. PUSH
b. POP
c. CHANGE
d. PEEP
e. TOP_OF_STACK
f. IS_EMPTY
g. IS_FULL
2) Applications of SQL
Introduction to SQL, Advantages of using SQL
Database concepts
SQL concepts and tools
The generic SQL Sentence Construct
Create Table
The Create Table Command
Creating a table from a table
Insertion of Data into tables
Inserting of data into a table
Inserting of data into a table from another table
Viewing data in the tables
View all rows and columns
Selected columns and all rows
Select rows and all columns
Selected columns and selected rows
Elimination of duplicates from the select statement
Sorting of data in a table
Delete Operations
Remove of all rows
Removal of a specified row(s)
Update Operations
Updating of all rows
Updating records conditionally
Modifying the structure of tables
Adding new columns
Modifying existing columns
Renaming Tables
Destroying Tables
Examining Objects created by a User
Arithmetic Operators
Logical Operators
Range Searching
Pattern Matching
Column Alias
Aggregate Functions
Scalar Functions
Date Conversion Functions
Data Constraints
Defining integrity constraints in the alter table command
Dropping integrity constraints in the alter table command
Default Value Concept
Grouping Data from tables
Manipulating dates in SQL
Subqueries, Joins, Union, Intersect and Minus Clause
Index, View, Sequence
Question 1
experience, email)
1. Create the above given tables with all necessary constraints such as
In EMP TABLE : Employee id should be primary key, Department no should be
Foreign key, employee age (birth_date) should be greater than 18 years,
salary should be greater than zero, email should have (@ and dot) sign in address,
designation of employee can be “manager”, “clerk”, “leader”, “analyst”, “designer”,
“coder”, “tester”.
2. After creation of above tables, modify Employee table by adding the constraints as
‘Male’ or ‘Female’ in gender field and display the structure .
3. Insert proper data (at least 5 appropriate records) in all the tables.
4. List all records of each table in ascending order.
5. Delete the department whose total number of employees less than 1.
6. Find the names of the employee who has salary less than 5000 and greater than 2000.
7. Display the names and the designation of all female employee in descending order.
8. Display the names of all the employees who names starts with ‘A’ ends with ‘A’.
9. Find the name of employee and salary for those who had obtain minimum salary.
10. Add 10% raise in salary of all employees whose department is ‘IT’.
11. Count total number of employees of ‘MCA’ department.
12. List all employees who born in the current month.
13. Print the record of employee and dept table as “Employee works in department ‘MBA’.
14. List names of employees who are fresher’s ( less than 1 year of experience).
15. List department wise names of employees who has more than 5 years of experience.
Question 2:
Question 4
27. Copy all M.P customers to the table with Gujarat customers
28. Rename Guj_cust table to MP_cust table.
29. Find the customers who are not in Gujarat or M.P
30. Delete rows from customer table that are also in MP_cust table
31. Find the items with top three prices
32. Find two items with lowest quantity on hand
33. Create a simple view with item names and item price only
34. Create a sequence that can be used to enter new items into item table
35. Add a new item into item table with sequence just created.
36. Create a index file to speed up a search based on customer name
37. Lock customer Mr. Shah record to update the state and phone no.
38. Give everybody select and insert rights on your item table
39. Revoke the insert option on item table from user ‘Roshi’.
Question 5:
Consider the DUAL and data dictionary tables/views to solve the following Queries.
Not Null
Name Varchar2 20
Address1 Varchar2 30
Address2 Varchar2 30
City Varchar2 15
State Varchar2 15
Pincode Number 6
Not Null
Description Varchar2 5
Not Null
Profit_percent Number 2,2
Not Null
Unit_measure Varchar2 10
Not Null
Qty_on_hand Number 8
Not Null
Recover_lvl Number 8 Not Null, cannot be 0.
Not Null
Salesman_name Varchar2 20
Not Null
Address1 Varchar2 30
Address2 Varchar2 30
City Varchar2 20
Pincode Varchar2 6
State Varchar2 20
Not Null, cannot be 0.
Sal_amt Varchar2 8,2
Not Null, cannot be 0.
Tgt_to_get Number 6,2
Not Null
Ytd_sales Number 6,2
Remarks Varchar2 60
Order_status Varchar2 10
ENROLLED(SNO, CLASSNAME)
Primary key and foregin key should be added as per basic requirements and also Following
Constraints should be added.
a. Level fields has values like ‘JR’ for junior and ‘SR’ for senior.
3. Find the name of all seniors (SR) who are enrolled in class taught by Ms. Rekha.
4. Find the name of students who are not enrolled in any class.
5. Find the name of all the classes that meet in Room R105.
Question 8:
The STATUS field tells us whether the room is occupied or vacant. The charges represent the
term fees to be paid half yearly. A student can pay either the annual fees at one time or the half
yearly fees twice a year.
Question 9:
TRAIN _MASTER:
PASSENGER_DETAILS:
IF MASTER RECORD IS
DELETED.
SEAT NUMBER NUMBER(2) NOT NULL
TRAIN_SEAT_MASTER:
TRAIN_DAY_MASTER:
Reference Books: