0% found this document useful (0 votes)
31 views26 pages

DDC Pratical - Exam Questions

The document contains a comprehensive question bank for a Database Management practical exam, including SQL commands for creating tables, inserting records, updating data, and querying information across various scenarios. It covers multiple entities such as Students, Employees, Books, Depositors, and more, providing examples of SQL syntax for each operation. Additionally, it includes tasks related to PL/SQL, such as creating sequences, views, and synonyms.
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)
31 views26 pages

DDC Pratical - Exam Questions

The document contains a comprehensive question bank for a Database Management practical exam, including SQL commands for creating tables, inserting records, updating data, and querying information across various scenarios. It covers multiple entities such as Students, Employees, Books, Depositors, and more, providing examples of SQL syntax for each operation. Additionally, it includes tasks related to PL/SQL, such as creating sequences, views, and synonyms.
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/ 26

Database Management 22416 Practical Exam

Question Bank with solutions


2022-23

1) Create table Students (Roll_no, Name, Age Address,


Date_of_Birth)
CREATE TABLE Students (Roll_no INT, Name VARCHAR(20), Age INT, Address VARCHAR(20),
Date_of_Birth DATE);

2) Insert 5 records.
INSERT INTO Students VALUES (1, 'John', 16, 'Pune', '2006/06/06');
INSERT INTO Students VALUES (2, 'Ajay', 15, 'Chennai', DATE '2023-02-02');
INSERT INTO Students VALUES (3, 'Ron', 12, 'Delhi', DATE'2010-12-08');
INSERT INTO Students VALUES (4, 'Joy', 16, 'Mumbai', DATE'2006-09-09'); //YYYY-MM-DD
INSERT INTO Students VALUES (5, 'Harry', 15, 'Hyderabad',DATE'2007-12-12');

3)Update address of all records if current address is Chennai UPDATE


Students SET Address= 'Nashik' WHERE Address= 'Chennai';

3) Select all records whose address is either Mumbai or Nashik


SELECT * FROM Students WHERE Address IN ('Mumbai','Nashik');

Consider the following database and create table for the same
Employee(emp_id,emp_name,emp_city,emp_addr,emp_dept,join_date)

CREATE TABLE Employee(emp_id int,emp_name varchar2(20), emp_city varchar2(20),


emp_addr varchar2(20),emp_dept varchar2(20), join_date DATE);

INSERT INTO Employee VALUES (1001, 'Ajay', 'Chennai', 'Chennai', 'Computer Engg', DATE
'2023-02-02');
INSERT INTO Employee VALUES (1002, 'Amit', 'Delhi', 'Delhi', 'Mechsnical Engg', DATE '2019-
02-02');
INSERT INTO Employee VALUES (1003, 'Mayur', 'Mumbai', 'Mumbai', 'Information Tech', DATE
'2012-04-23');
INSERT INTO Employee VALUES (1004, 'Mangesh', 'Pune', 'Pune', 'Mechanical Engg',
DATE '1999-04-15');

i) Display the emp_id of employee who live in city 'Pune' or 'Delhi' select
emp_id from Employee where emp_city='Pune' or emp_city-'Delhi';

ii) Change the employee name 'Ajay' to


'Anil'
update Employee set emp_name='Anil'where
emp_name='Ajay';

iii) Display the total number of employee whose dept is 50


Select count(*) from Employee where emp_dept=50;

Create table Students(Roll_no, Stud_name, branch, class, DOB, city,


Contact_no)

Create table student123 (


Rollno number(5),
Stud name char(30),
-

branch varchar(30),
class varchar(30),
DOB date,

city varchar(30),
Contact_no number(12)
);

(i) Insert one row into the table:


SQL>Insert into student123 values(1, 'Ram','CO', 'First Year', '12-jun-2001', 'Pune',98576867);

(ii) Save the data:


SQL> commit; (OR) SQL> commit work;

(iii) Insert second row into the table:


SQL>Insert into student123 values (2, 'Raj', 'CO', 'First Year', '22-Sep-2002',
'Mumbai',98896863);

(iv)Undo the insertion of second row:


SQL> rollback; (OR)
SQL> rollback work;

(v)Create savepoint s1:


SQL>Savepoint s1;
);
(vi) insert one row into the table:
SQL>Insert into student123 values(3, 'Beena', 'CO', 'First Year', '30-Dec-2002', 'Mumbai',97846455);

Create table for EMP (empno, deptno, ename, salary, designation, join_date,DOB,
dept_location). Write down SQL queries for following:

CREATE TABLE EMP

(
empno INT,
deptno INT,
ename VARCHAR2(30),
salary INT,
designation VARCHAR2(30),
join_date DATE,
DOB DATE,
dept_location VARCHAR2(30)

INSERT INTO EMP VALUES (1001, 20,'Amit', 50000, 'Manager', DATE '2019-02-02',
DATE '1982- 05-02','Mumbai');
INSERT INTO EMP VALUES (1002, 20,'Peter', 70000, 'Sr. Manager', DATE '2015-08-12',
DATE '1992-05-22','Pune');
INSERT INTO EMP VALUES (1003, 10,'Sharan', 40000, 'Manager', DATE '2012-04-12', DATE
'1987-06-18','Nashik');

(i)Display employees name &number in descending order of


salary:
SQL> select ename,empno from EMP order by salary
desc;

(ii) Display employee name & employee number whose


designation is Manager. SQL> select ename,empno from EMP where
designation='Manager';
(iii) Display age of employees with ename
SQL>select round ((sysdate - DOB ) /365, 0 ) as
"age",ename from EMP;
(iv)Display total salary of all employees.
SQL> select sum(salary) from EMP;

(v)Display employee names having deptno as 20 and


dept_location is Mumbai. SQL> select ename from EMP where
deptno-20 and dept_location='Mumbai';

(vi)Display name of employee who earned lowest salary


SQL> select ename from EMP where salary-(select min(salary) from EMP);

(vii)Display name of employee who earned highest salary


SQL> select ename from EMP where salary=(select max(salary) from EMP);

Consider the structure for book table as BookMaster123 (bookid,bookname, author, no_of copies, price)
Write down SQL queries for following:
(i) Write a command to create Bookmaster123 table and insert min 5 records in it

SQL>Create table BookMaster123


(
bookid number(5),
bookname varchar2(60),
author varchar2(60),
no_of_copies number(5),
price number(10,2)
);

INSERT INTO BookMaster123 VALUES (1001, 'Programming In C', 'Dennis Ritchie', 5000, 400.00);
INSERT INTO BookMaster123 VALUES (1001, 'Java Programming', 'E Balagurusamy', 8000, 800.00);
INSERT INTO BookMaster123 VALUES (1001, 'Data Structures Using C', 'Dr. E. F. Codd', 2000, 300.00);
INSERT INTO BookMaster123 VALUES (1001, 'Operating System', 'Navathe', 1000, 500.00); INSERT
INTO BookMaster123 VALUES (1001, 'Advanced Java Programming', 'E Balagurusamy', 3000,
700.00);

(ii)Get authorwise list of all books.


SQL>Select sum(no_of_copies) from BookMaster123 group by author;

(iii)Display all books whose price is between Rs.500 & Rs. 800
SQL> Select * from BookMaster123 where price between 500 and 800;
OR

SQL> Select * from BookMaster123 where price >=500 and


price<=800;

(iv) Display all books with details whose name start with 'D'
SQL> Select bookname from BookMaster123 where bookname like 'D%';

(v)Display all books whose price is above Rs.700


SQL>Select * from BookMaster123 where price >700;

(vi) Display all books whose number of copies are less than
10
SQL>Select * from BookMaster123 where
no_of_copies<7000;

Consider following schema:


Depositor (cust_name, acc_no)
Borrower (cust_name, loan_no)
1) Create table Depositor and Borrower
CREATE TABLE Depositor (cust_name VARCHAR2(30), acc_no
NUMBER(10)); CREATE TABLE Borrower (cust_name VARCHAR2(30),
loan_no NUMBER(10));

2) Insert records in Depositor


INSERT INTO Depositor VALUES ('Dennis Ritchie', 1234567890);
INSERT INTO Depositor VALUES ('E Balagurusamy', 1237537897);
INSERT INTO Depositor VALUES ('Dr. E. F. Codd', 1234561521);
INSERT INTO Depositor VALUES ('Dennis Ritchie', 1234671289);

3) Insert records in Borrower


INSERT INTO Borrower VALUES ('Dennis Ritchie', 1234567890); INSERT
INTO Borrower VALUES ('E Balagurusamy', 1237537897); INSERT
INTO Borrower VALUES ('Dr. E. F. Codd', 1234561521); INSERT
INTO Borrower VALUES ('Dennis Ritchie', 1234671289);

Solve following queries:


i) Find customer name having saving account as well as loan account:
Select d.Cust_name From depositor d, borrower b Where d.
Cust_name-b.cust_name;

(ii) Find customer names having loan account but not the savings
account:
Select b.cust_name from borrower b minus Select d.cust_name from depositor d
Where d.cust_name=b.cust_name;

Create table and perform following operations:


Student_data(rollno,name, address, DOB and percent)

create table student_data

(
rollno number(5),
name char(20),
address varchar2(40),
DOB date,
percent number(5,2)
);

i) Insert 5 records in table

INSERT INTO Student_data VALUES (1, 'John', 'Pune', DATE


'1982-05-02',90.00); INSERT INTO Student_data VALUES (2, 'Ajay', 'Chennai',
DATE '2023-02-02',60.65); INSERT INTO Student_data VALUES (3, 'Ron',
'Delhi', DATE'2010-12-08',45.23);
INSERT INTO Student_data VALUES (4, 'Joy', 'Mumbai', DATE'2006-09-09',77.36);
//YYYY-MM-
DD

INSERT INTO Student_data VALUES (5, 'Harry',


'Hyderabad',DATE'2007-12-12',84.89);

ii) Add column city char(20) in table;


alter table student_data add (city char(20));

iii) rename student to student_info;


rename student_data to student_info;

iv)Remove/delete the data or records from student info


table:
delete from student_info;
OR
truncate table student_info;
1) Create table students_Info (roll_no, name,city, percentage,
result). Write queries for the following:

Create table students_Info ( rollno


number(5), Stud_name char(30),
city varchar(30),
percentage number(4,2),
result varchar(30)
);

2) Insert Records
INSERT INTO Students_Info VALUES (1, 'John', 'Pune', 90.00,'Distiction');
INSERT INTO Students_Info VALUES (2, 'Ajay', 'Chennai',
60.65,'First Class'); INSERT INTO Students_Info VALUES (3, 'Ron', 'Delhi',
45.23,'Pass Class'); INSERT INTO Students_Info VALUES (4, 'Joy', 'Mumbai',
77.36,'First Class'); INSERT INTO Students_Info VALUES (5, 'Harry',
'Hyderabad',84.89,'Distiction');

(i) Display all students having result as first class:


Select * from students Info where result='First Class';
(ii) Update roll_no of each student by adding 18 to it:
update students_Info set rollno=rollno+18;

(iii) Delete percent column from table:


alter table students_Info drop column percentage;

iv) Display all the records with city as Mumbai.


select * from students_Info where city="Mumbai';

Create tables for following schemas and insert records in both tables.
Stud(rollno, Stud_name, dt_of_birth,telephone)
Marks (rollno, sub1_marks, sub2_marks, per)

Create table stud ( rollno


number(5), Stud name
char(30), dt of birth date,
telephone number(10)
);

INSERT INTO Stud VALUES (1, 'John', DATE


'1982-05-02',12121212); INSERT INTO Stud VALUES (2, 'Ajay',
DATE '2023-02-02',4545454545); INSERT INTO Stud VALUES (3,
'Ron', DATE'2010-12-08',7878787878); INSERT INTO Stud
VALUES (4, 'Joy', DATE'2006-09-09',5656565656); INSERT
INTO Stud VALUES (5, 'Harry', DATE'2007-12-12',9999999999);

Create table marks (


rollno number(5),
sub1_marks int, sub2
marks int,
per number(4,2)
);

INSERT INTO marks VALUES (1, 55, 77, 66);


INSERT INTO marks VALUES (2, 66, 88, 77);
INSERT INTO marks VALUES (3, 77, 99, 88);
INSERT INTO marks VALUES (4, 44, 66, 55);
INSERT INTO marks VALUES (5, 33, 55, 44);

Write SQL queries for the following.


>

i) Display student's rollno, name, and marks of both subjects for all students.
Ans:

Select Stud.rollno, Stud.Stud_name, marks.sub1_marks,marks.sub2_marks from Stud, marks


where Stud.rollno-marks.rollno;

ii) Delete all those students records who secured less than 35%
Ans: Delete from Stud where rollno=(Select rollno from marks where per<55);

iii)Display all the students whose name start with 'A'


Ans: Select Stud name from Stud where Stud name like 'A%';
(OR)
Select * from Stud where Stud name like 'A%';

iv)Update telephone number of student with rollno 1 as


9800010111 Ans: Update Stud set telephone-9800010111 where
rollno=1;

Create tables for following schemas and insert records in both tables.
empl{empid,empname,designation,salary,deptno}
And

dept { deptno,deptname, location}

CREATE TABLE Empl

empid INT,
ename VARCHAR2(30),
designation VARCHAR2(30),
salary INT,
deptno INT

CREATE TABLE Dept


);
deptno INT,
deptname VARCHAR2(30),
location VARCHAR2(30)

INSERT INTO Empl VALUES (1001, 'Amit', 'Manager',20000,10);


INSERT INTO Empl VALUES (1002, 'Peter', 'Sr. Manager',40000,
10); INSERT INTO Empl VALUES (1003, 'Sharan', 'Manager',30000,
20 ); INSERT INTO Empl VALUES (1001, 'Amit', 'Manager', 50000, 20);
INSERT INTO Empl VALUES (1002, 'Peter', 'Sr.
Manager',35000, 10);

INSERT INTO Dept VALUES (10,'Information Technology',


'Nashik'); INSERT INTO Dept VALUES (20,'Computer Engg.',
'Mumbai');
INSERT INTO Dept VALUES (20, 'Information Technology', 'Pune');
INSERT INTO Dept VALUES (10,'Computer Engg.',
'Nashik');

Write SQL queries for following:

i)Find maximum salary for deptno=10;


Ans:Select max(salary) from Empl where deptno=10;

ii) Increase salary of all employee by 5% Ans:


Update empl set salary-salary+(salary*0.05);

iii) Get the names of all 'Manager'.


Ans: Select ename from empl where designation='Manager';

iv) Display deptnames located at 'Pune' and 'Nagpur'.


Ans: Select deptname from dept where location='Pune' or location='Nashik';
Create table Person {personid, name, address, city,
telephone}

CREATE TABLE Person

(personid INT,

);
name VARCHAR(30),
address VARCHAR(30),
city VARCHAR(30),
telephone NUMBER(10)

Write PL/SQL queries for following:

i) Create sequence seq-pid with start value 100 and maximum value 120 and increment by 1.
Use seq-pid to insert personid into table person.

Create sequence seq_pid start with 100 increment by 1 maxvalue


120;

Insert into person (personid) values (seq_pid.nextval);

ii) Create view view-person containing details of persons from city "Mumbai" and
"Pune"

Create view view_person as select * from person where city-'Mumbai' or


city="Pune';
Or
Create view view_peson as select * from persons where city in
('Mumbai','Pune');

iii) Create synonym syn-person on table person owned by user 'Scott' delete
synonym syn-person.

create synonym syn_person for system.person; // system is login


username

Drop synonym syn_person;

Write a PL/SQL code to accept value of sales from employee and display its
comission.
if sales > 200000 them comission is 1 percentage of sales.
if sales <= 200000 AND n_sales > 100000 comission is 0.5
percentage of sales.
sales <= 100000 AND n_sales > 50000 comission is 0.3 percentage of
sales.
otherwise comission is 0.2 percentage of
sales.

SQL> SET SERVEROUTPUT ON;

DECLARE

n_sales NUMBER := &n_sales; --300000;

n_commission NUMBER( 10, 2) := 0;

BEGIN

IF n_sales > 200000 THEN

n_commission := n_sales * 0.1;

ELSIF n_sales <= 200000 AND n_sales > 100000 THEN

n commission := n_ sales * 0.05;

ELSIF n_sales <= 100000 AND n_sales > 50000 THEN

END IF;
n_commission := n_sales * 0.03;

ELSE
n_commission := n_sales * 0.02;

DBMS_OUTPUT.PUT_LINE ('COMMISSION:'|| n_commission);

END;

Write PL/SQL code to table of accepted number from user.

DECLARE

VARI NUMBER:=&VAR1;

VAR2 NUMBER;

BEGIN

VAR2:=1;

LOOP

DBMS_OUTPUT.PUT_LINE (VAR1*VAR2);

IF (VAR2=10) THEN

EXIT;

END IF;

VAR2: VAR2+1;

END LOOP;

END;

Write PL/SQL code to display 1 to 10 numbers in reverse


order.
otherwise comission is 0.2 percentage of sales.
/
SQL> SET SERVEROUTPUT ON;

DECLARE

n_sales NUMBER := &n_sales; --300000;

n_commission NUMBER( 10, 2) := 0;

BEGIN

IF n_sales > 200000 THEN

n_commission := n_sales * 0.1;

ELSIF n_sales <= 200000 AND n sales> 100000 THEN

n_commission := n_sales * 0.05;

ELSIF n_sales <= 100000 AND n_sales > 50000 THEN


END IF;
n_commission := n_sales * 0.03;

ELSE

n_commission := n_sales * 0.02;

DBMS_OUTPUT.PUT_LINE ('COMMISSION:'|| n_commission);

END;

Write PL/SQL code to table of accepted number from user.

DECLARE

VARI NUMBER:=&VAR1;

VAR2 NUMBER;

BEGIN

VAR2:=1;

LOOP

DBMS_OUTPUT.PUT_LINE (VAR1*VAR2);

IF (VAR2=10) THEN

EXIT;

END IF;

VAR2: VAR2+1;

END LOOP;

END;
Write PL/SQL code to display 1 to 10 numbers in reverse
order.
DECLARE

VARI NUMBER;

BEGIN

VAR1:=10;

FOR VAR2 IN REVERSE 1..10

LOOP

DBMS_OUTPUT.PUT_LINE (VAR1*VAR2);
END LOOP;

END;

Write a PL/SQL program which accepts the customer_ID from the user. If theenters
an invalid ID then the exception invalid_id is raised using exception handling.
DECLARE

c_id numeric(10);

invalid_id_Exception Exception;
BEGIN

c_id:=&c_id;

if(c_id<0) then

raise invalid_id_Exception;

end if;

EXCEPTION

WHEN invalid_id_Exception THEN

dbms_output.put_line('Invalid customer id');

END;
/

Write a PL/SQL code to raise zero_divide exception, in case of division of a number


by another
DECLARE

A number:=20;

B number:=0;

C number;

BEGIN

dbms_output.put_line('First Num: '||A);


dbms_output.put_line('Second Num: '||B);
C:=A/B; --Raise Exception
dbms_output.put_line(' Result ' ||
C);
EXCEPTION

WHEN ZERO_DIVIDE THEN

dbms_output.put_line(' Trying to Divide by zero :: Error ');


END;

Create a table customers(id, name, address).


Insert 5 records int it.

Write a PL/SQL code to accept customer id from user display its name and address if found.
If record not found then display message "No such customer!"
create table customers

id number(5),
name char(30),

address varchar2(40)

);

Insert 5 records in table

INSERT INTO customers VALUES (1, 'John', 'Pune');

INSERT INTO customers VALUES (2, 'Ajay', 'Chennai');

INSERT INTO customers VALUES (3, 'Ron', 'Delhi');

INSERT INTO customers VALUES (4, 'Joy', 'Mumbai');

INSERT INTO customers VALUES (5, 'Harry', 'Hyderabad');

DECLARE

c_id customers.id%TYPE := &id;

c_name customers.name% TYPE;


c_addr customers.address% TYPE;

BEGIN

SELECT name, address INTO c_name, c_addr

FROM customers

WHERE id = c_id;

DBMS_OUTPUT.PUT_LINE ('Name: ' || c_name);


DBMS_OUTPUT.PUT_LINE ('Address: ' || c_addr);

EXCEPTION

WHEN NO_DATA_FOUND THEN


dbms_output.put_line('No such
customer!');
WHEN others THEN

dbms_output.put_line('Error!');
END;
Create a table customers(id, name, address).
Insert 5 records int it.

Write a PL/SQL code to accept customer id from user display its name and address if found.
If record not found then display message "No such customer!"
If customer id is less than zero the raise an user defined exception invalid ID.
create table customers

id number(5),

name char(30),

address varchar2(40)

);

Insert 5 records in table

INSERT INTO customers VALUES (1, 'John', 'Pune');

INSERT INTO customers VALUES (2, 'Ajay', 'Chennai');

INSERT INTO customers VALUES (3, 'Ron', 'Delhi');

INSERT INTO customers VALUES (4, 'Joy', 'Mumbai');

INSERT INTO customers VALUES (5, 'Harry', 'Hyderabad');

DECLARE

c_id customers.id%TYPE := &c_id;

c_name customers.name%TYPE;

c_addr customers.address%TYPE;

ex_invalid_id EXCEPTION; -- user defined exception declaration


BEGIN

IF c_id <= 0 THEN


RAISE ex_invalid_id;

ELSE
Raise user defined exception

SELECT name, address INTO c_name, c_addr

FROM customers

WHERE id = c_id;
dbms_output.put_line ('Name: '|| c_name);
dbms_output.put_line ('Address: ' || c_addr);
END IF;

EXCEPTION

END;
WHEN ex_invalid_id THEN
--

- implementation defined exception

dbms_output.put_line('ID must be greater than


zero!');
WHEN NO_DATA_FOUND THEN

dbms_output.put_line('No such customer!');


WHEN OTHERS THEN

dbms_output.put_line('Error!');

Create a table customers(id, name,


address).
Insert 5 records int it.

Write a PL/SQL code with cursor to display all records of id, name and address
from customer
table.

create table customers

id number(5),

name char(30),

address varchar2(40)

);

Insert 5 records in table

INSERT INTO customers VALUES (1, 'John', 'Pune');

INSERT INTO customers VALUES (2, 'Ajay', 'Chennai');

INSERT INTO customers VALUES (3, 'Ron', 'Delhi');

INSERT INTO customers VALUES (4, 'Joy', 'Mumbai');

INSERT INTO customers VALUES (5, 'Harry', 'Hyderabad');

DECLARE

c_id customers.id%TYPE;
c_name customers.name% TYPE;

c_addr customers.address%
TYPE;
CURSOR c_customers IS
SELECT id, name, address FROM
customers;
BEGIN
OPEN c_customers;

LOOP

FETCH c_customers into c_id, c_name,


c_addr;

EXIT WHEN
c_customers%NOTFOUND;

dbms_output.put_line(c_id ||'' || c_name || '' ||


c_addr);
END LOOP;

CLOSE c_customers;

END;

Write procedure that takes two numbers using the IN-mode


parameter and returns their minimum using the OUT mode parameters.
SQL> SET SERVEROUTPUT ON;

DECLARE

a number;

b number;

c number;

PROCEDURE findMin(x IN number, y IN number, z OUT number) IS

BEGIN

IF x <y THEN

Z:= x;

ELSE

z:= y;

END IF;
END;

BEGIN

a:= &a;

b:= &b;

findMin(a, b, c);

dbms_output.put_line(' Minimum of ('|| a


||','||b||') : ' || c);
END;

Write PL/SQL Code to compute square of value of a


passed value.

DECLARE
a number;

PROCEDURE squareNum(x IN OUT number) IS


BEGIN

X := x * X;

END;

BEGIN

a:= &a;

squareNum(a);

dbms_output.put_line(' Square of (23): ' || a);


END;

Write PL/SQL Code e to calculate the factorial of a number accepted from user by calling
itself
recursively.

DECLARE

num number;

factorial number;

FUNCTION fact(x number)

RETURN number

IS

f number;

BEGIN

IF x=0 THEN

f:= 1;

ELSE

f:= x* fact(x-1);

END IF;

RETURN f;

END;

BEGIN

num:= &num;

factorial := fact(num);

dbms_output.put_line(' Factorial '|| num || ' is ' || factorial);

END;
Write a PL/SQL program to print n even numbers using For
Loop.
DECLARE

num number;

n number:=&n;

BEGIN
dbms_output.put_line('Even no are :');

FOR num in 1..n loop

IF(mod(num,2)=0) then

dbms_output.put_line(num);

END IF;

END LOOP;

END;

Write a PL/SQL program to print sum of 1 to n numbers where n is accepted from


user.
DECLARE

i number(10);

ans number(10);

n number(10):=&n;

BEGIN

ans:=0;

i:=1;

while i<=n

LOOP

ans:=ans+i;

i:=i+1;

END LOOP;

dbms_output.put_line('Sum of 1 to'||n' numbers


is:'||ans);

END;
/

Write SQL command for following


i) create user 'Rahul'
Ans: create user Rahul identified by rahul1234;
ii) assuming table Employee for granting permissions to user 'Rahul' for select, insert,
update and delete privilege)
Ans: Grant select, insert,update, delete on employee to Rahul;

iii) for create and drop privilege which are system privileges not specific to any object such as table
Ans: Grant connect, resource, DBA to Rahul;

iv) (assuming table Employee for revoking permissions to user


'Rahul')
Ans: Revoke select on Employee from Rahul;

create user c##chintamani identified by 123;

You might also like