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

sql queries

Uploaded by

blesswinsj12
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

sql queries

Uploaded by

blesswinsj12
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

a) Create a table student with following information fields: rollno with numeric type, name, and branch as
string data type. Do the following operations
i. Alter table by adding primary key for column rollno.
ii. Increase or decrease the size of branch column.
iii. Add new column called class with string type, having length 20.
iv. Remove column branch
v. Change the name of the table from student to stud
vi. Remove the primary key constraint.
vii. Remove all the records from the table without using delete command
viii. Remove the entire table structure and its records

1.a) Write a PL/SQL block to evaluate the grade of the student from the student table by accepting student
number. Attributes of student table is studno , studname, mark1, mark2, mark3

1. a) Consider the following relations for an order processing database in a company


CUSTOMER (cust #: number , cname: varchar2, city: varchar2)
ORDER (order #: number, odate: date, cust #: number, ord-Amt: number)
i. Create the above tables by properly specifying the primary keys and the foreign keys.
ii. Demonstrate the following features with foreign keys
1.when records in the parent tables are deleted, then dependency records in the child table
should automatically dropped
2.When attempts are made to delete a record from parent table, which contains dependence
record in child table , then it should not delete a record from parent table.
iii. Alter tables with ALTER TABLE option to
9 add a check constraint that validate value of column ord_amt in between Rs.10,000 and
Rs.1,00,000.
9 add default constraints for column odate
9 add not null constraints for column cname.

1. a) Create a table employee with attributes empno, ename, job(i.e., designation), mgr, hiredate,
sal, commission, deptno. And table department with attributes deptno, dname, loc.
i. How many clerks are there in the company?
ii. Which department has exactly one employee as clerk?
iii. Which department has the highest number of clerks? Show the deptno and count.
iv. How many employees are there in each department?
v. List the lowest salary for different jobs used in a company and list them in descending order.
vi. Which department average salary is the lowest among all? Show the deptno, average salary.
vii. List the minimum, maximum and average salary for each job.
viii. List the names of the employees whose name starts with LA.
ix. List the names of the employees whose name contains LA.
x. List the names of the employees whose name ends with KE.
xi. List the minimum and maximum salaries.
xii. Compute the difference between maximum and minimum salary
b) Create a trigger that should put restriction on user, who trying to insert or delete or modify
records on employee table, either on week end or on non working hours.
Note: Assume that working hours is 8.00 A.M to 8.00 P.M on all week days (Monday to Friday)

1. a) Create a table
Order (order_id number (5), person_id number(3), odate date) Person (person_id number (3),
lastname varchar2 (20), firstname varchar2 (20), address varchar2(20))
Demonstrate the following Join operations
a. Inner join
b. left outer join
c. right outer join
d. full outer join

1. a) Create a table student with following information fields: rollno with numeric type, name, and
branch as string data type. Do the following operations
[

i. Alter table by adding primary key for column rollno.


ii. Increase or decrease the size of branch column.
iii. Add new column called class with string type, having length 20.
iv. Remove column branch
v. Change the name of the table from student to stud
vi. Remove the primary key constraint.
vii. Remove all the records from the table without using delete command
viii. Remove the entire table structure and its records

b) Write a PL/SQL program to generate multiplication tables for 2, 4, and 6

You might also like