0% found this document useful (0 votes)
79 views

Dbms Record Outputs

The document describes creating and manipulating tables using SQL DDL and DML commands. It includes: 1. Creating an Employee table with columns for details like name, job, salary. 2. Creating a Department table with columns for department number, name, location. 3. Creating a Customer table with columns for customer details. It then provides examples of inserting, updating, deleting records from these tables and adding or modifying columns using SQL commands like ALTER, INSERT, UPDATE, DELETE.

Uploaded by

sufiyanwrites
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Dbms Record Outputs

The document describes creating and manipulating tables using SQL DDL and DML commands. It includes: 1. Creating an Employee table with columns for details like name, job, salary. 2. Creating a Department table with columns for department number, name, location. 3. Creating a Customer table with columns for customer details. It then provides examples of inserting, updating, deleting records from these tables and adding or modifying columns using SQL commands like ALTER, INSERT, UPDATE, DELETE.

Uploaded by

sufiyanwrites
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

CREATION OF TABLES

1. Create a table called Employee with the following structure.

Name Type
Empno Number
Ename Varchar2(10)
Job Varchar2(10)
Mgr Number
Sal Number

a. Add a column commission with domain to the Employee table.


b. Insert any five records into the table.

c. Update the column details of job


d. Rename the column of Employ table using alter command.

e. Delete the employee whose empno is 105.


2. Create department table with the following structure.

Name Type
Deptno Number
Deptname Varchar2(20)
location Varchar2(20)

a. Add column designation to the department table.

b. Insert values into the table.


c. List the records of department table grouped by deptno.

d. Update the record where deptno is 9.


e. Delete any column data from the table
3. Create a table called Customer table
Name Type
Cust name Varchar2(20)
Cust street Varchar2(20)
Cust city Varchar2(20)

a. Insert records into the table.

b. Add salary column to the table.


c. Alter the table column domain.

d. Drop salary column of the customer table.

e. Delete the rows of customer table whose cust_city is „hyd‟.


QUERIES USING DDL AND DML

1.
a. Create a user and grant all permissions to the user.

b. Insert the any two records in the employee table and use rollback. Check the
result.
c. Add primary key constraint and not null constraint to the employee table.
d. Insert null values to the employee table and verify the result.
2.
a. Create a user and grant all permissions to the user.

b. Change password of the user created.

c. Insert values in the department table and use commit.


d. Add constraints like unique and not null to the department table.

e. Insert repeated values and null values into the table.


f. Add save point after insertion of records and verify save point.

g. Use revoke command to remove user permissions.


h. Delete constraint not null to the table column
3.
a. Create a user and grant all permissions to the user.

b. Insert values into the table and use commit.

c. Delete any three records in the department table and use rollback.
d. Add constraint primary key and foreign key to the table.
QUERIES USING AGGREGATE FUNCTIONS

1. a. By using the group by clause, display the enames who belongs to deptno 10
along with average salary.

b. Display lowest paid employee details under each department.

c. Display number of employees working in each department and their


department number.
d. Using built in functions, display number of employees working in each
department and their department name from dept table. Insert deptname
to dept table and insert deptname foreach row, do the required thing
specified above.

e. List all employees which start with either B or C.

f. Display only these ename of employees where the maximum salary is


greater than or equal to 5000.
2. a. Calculate the average salary for each different job.

b. Show the average salary of each job excluding manager.

c. Show the average salary for all departments employing more than three
people.
d. Display employees who earn more than the lowest salary in department 30
e. Show that value returned by sign (n)function.

f. How many days between day of birth to currentdate.


3.
a. Show that two substring as singlestring.

b. List all employee names, salary and 15% rise in salary.


c. Display lowest paid emp details under each manager

d. Display the average monthly salary bill for each deptno.


e. Show the average salary for all departments employing more than two people.

f. By using the group by clause, display the eid who belongs to deptno 05 along
with average salary.
4.
a. Count the number of employees in department 20

b. Find the minimum salary earned by clerk.

c. Find minimum, maximum, average salary of all employees.

d. List the minimum and maximum salaries for each job type.
e. List the employee names in descending order.

f. List the employee id, names in ascending order by empid.


PROGRAMS ON PL/SQL

1. a. Write a PL/SQL program to swap two numbers.


b. Write a PL/SQL program to find the largest of three numbers.
2. a. Write a PL/SQL program to find the total and average of 6 subjects and
display the grade.
b. Write a PL/SQL program to find the sum of digits in a given number.
3. a. Write a PL/SQL program to display the number in reverse order.
b. Write a PL/SQL program to check whether the given number is prime or not.
4. a. Write a PL/SQL program to find the factorial of a given number.

b. Write a PL/SQL code block to calculate the area of a circle for a value of
radius varying from 3 to 7. Store the radius and the corresponding values of
calculated area in an empty table named areas, consisting of two columns radius
and area.
5. a. Write a PL/SQL program to accept a string and remove the vowels from
the string. (When “hello” passed to the program it should display “Hll”
removing e and o from the word Hello).

b. Write a PL/SQL program to accept a number and a divisor. Make sure the
divisor is less than or equal to 10. Else display an error message. Otherwise
Display the remainder in words.
PROCEDURES AND FUNCTIONS

1. Write a function to accept employee number as parameter and return Basic


+HRA together as single column.
2. Accept year as parameter and write a Function to return the total net salary
spent for a given year.
3. Create a function to find the factorial of a given number and hence find ncr.
4. Write a PL/SQL block o pint prime Fibonacci series using local functions.

5. Create a procedure to find the lucky number of a given birthdate.


6. Create function to reverse the given number
TRIGGERS

1. Create a row level trigger for the customers table that would fire for INSERT
or UPDATE or DELETE operations performed on the CUSTOMERS table. This
trigger will display the salary difference between the old values and new values:

CUSTOMERS table:

ID NAME AGE ADDRESS SALARY


1 Alive 24 Khammam 2000
2 Bob 27 Kadappa 3000
3 Catri 25 Guntur 4000
4 Dena 28 Hyderabad 5000
5 Eeshwar 27 Kurnool 6000
6 Farooq 28 Nellur 7000
2. Convert employee name into uppercase whenever an employee record is
inserted or updated. Trigger to fire before the insert or update.
3. Creation of insert trigger, delete trigger, update trigger practice triggers using
the passenger database.
Passenger (Passport_ id INTEGER PRIMARY KEY, Name VARCHAR (50)
Not NULL, Age Integer Not NULL, Sex Char, Address VARCHAR (50) Not
NULL);
A. Write an Insert Trigger to check the Passport_id is exactly six digits or not.
B. Write a trigger on passenger to display messages “1 Record is inserted”, “1
record is deleted”, “1 record is updated” when insertion, deletion and updation
are done on passenger respectively.
4. Insert row in employee table using Triggers. Every trigger is created with
name any trigger have same name must be replaced by new name. These
triggers can raised before insert, update or delete rows on data base. The main
difference between a trigger and a stored procedure is that the former is attached
to a table and is only fired when an INSERT, UPDATE or DELETE occurs.
PROCEDURES

1. Create the procedure for palindrome of given number.


2. Create the procedure for GCD: Program should load two registers with
two Numbers and then apply the logic for GCD of two numbers. GCD of
two numbers is performed by dividing the greater number by the
smaller number till the remainder is zero. If it is zero, the divisor is the
GCD if not the remainder and the divisors of the previous division are the
new set of two numbers. The process is repeated by dividing greater of
the two numbers by the smaller number till the remainder is zero and
GCD is found.

3.Write the PL/SQL programs to create the procedure for factorial of


given number.
4. Write the PL/SQL programs to create the procedure to find sum of N
natural number.

5. Write the PL/SQL programs to create the procedure to find Fibonacci


series.
6. Write the PL/SQL programs to create the procedure to check the given
number is perfect or not

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy