Sy Dip - Dbms Super 25 With Answer by Shivam Sir
Sy Dip - Dbms Super 25 With Answer by Shivam Sir
Count()
Sum()
Avg()
Min()
Max()
Example:
declare
name emp_details.ename%type;
cursor a is select ename from emp_details where
empno=3;//cursor declaration
begin
open a;//opening the cursor
loop
fetch a into name;//fetching the rows from cursor
update emp_details set comm=3000 where empno=3;
exit when a%notfound;
dbms_output.put_line('record updated');
end loop;
close a;//closing the cursor
end;
Addition Operator(+)
Multiplication Operator (-)
Division Operator (/)
Modulus Operator (%)
AND operator
OR operator
BETWEEN operator
IN operator
NOT operator
ANY operator
LIKE operator
External level
Conceptual level
Internal level
External level
It is also called view level because several users can view their
desired data from this level which is internally fetched from
database with the help of conceptual and internal level mapping.
The user doesn’t need to know the database schema details such
as data structure; table definition etc. user is only concerned
about data which is what returned back to the view level after it
has been fetched from database which is present at the internal
level. External level is the top level of the three level DBMS
architecture.
Conceptual level
Internal level
This level is also known as physical level. This level describes how
the data is stored in the storage devices. This level is also
responsible for allocating space to the data. This is the lowest
level of the architecture.
V2V EdTech LLP | DBMS | Super 25 Questions with Solution
Q16. Write SQL queries for following: i) Create table student with
following attributes using suitable data types. Roll no., as primary
key, name, marks as not null and city. ii) Add column Date of
Birth in above student table. iii) Increase the size of attribute
name by 10 in above student table. iv) Change name of Student
table to stud.
ANS:
CREATE INDEX
Syntax:
V2V EdTech LLP | DBMS | Super 25 Questions with Solution
Example:
DROP INDEX
Example:
DROP INDEX id_firstname ON Student;
declare
n number;
i number;
rev number:=0;
r number;
begin
n:=&n;
V2V EdTech LLP | DBMS | Super 25 Questions with Solution
r:=mod(n,10);
rev:=(rev*10)+r;
n:=trunc(n/10);
end loop;
dbms_output.put_line('reverse is '||rev);
end;
Syntax:
DECLARE ;
Declaration section
…executable statement;
EXCEPTION
WHEN ex_name1 THEN ;
Error handling statements/user defined action to be carried out;
END;
Types of Exception:
JOIN:
Syntax:
SELECT tablename.column1_name,tablename.column1_name
FROM table_name1 inner join table_name2 ON
table_name1.column_name=table_name2.column_name;
Example:
Select stud_info.stud_name, stud_info.branch_code,
branch_details.location From stud_info inner join branch_details
ON Stud_info.branch_code=branch_details.branch_code;
2. LEFT OUTER JOIN: A left outer join retains all of the rows of
the “left” table, regardless of whether there is a row that
matches on the “right” table.
V2V EdTech LLP | DBMS | Super 25 Questions with Solution
Syntax:
Example:
3) RIGHT OUTER JOIN: A right outer join retains all of the rows of
the “right” table, regardless of whether there is a row that
matches on the “left” table.
Syntax:
Example:
Syntax:
V2V EdTech LLP | DBMS | Super 25 Questions with Solution
Example:
database.
Q25. Write and Explain the syntax for creating database trigger.
ANS:
Database trigger:
Triggers can be referred as stored procedures that are fired or
executed when an INSERT, UPDATE or DELETE statement is given
against the associated table.
Syntax:
Example:
Recovery Techniques:
1. Log based recovery.
2. Shadow paging recovery
3. Checkpoints
Q27. Write the SQL queries for following EMP table. Emp
(empno, deptno, ename, salary, designation, city.) i) Display
average salary of all employees. ii) Display names of employees
who stay in Mumbai or Pune. iii) Set the salary of employee
'Ramesh' to 50000. iv)Display names of employees whose salaries
are less than 50000. v) Remove the Record of employees whose
deptno is 10. vi) Remove the column deptno from EMP table.
ANS:
i. select avg(salary) from emp;
ii. select ename from emp where city=’Mumbai’ or city=’Pune’;
iii. update emp set salary=50000 where ename=’Ramesh’;
iv. select ename from emp where salary<50000;
v. delete from emp where deptno=10;
vi. alter table emp drop column deptno;
Q28. Write and Explain the syntax for creating, Altering and
dropping the sequence.
ANS:
Syntax for creating sequence:
Example:
Alter sequence:
Syntax:
alter sequence <sequence name> maxvalue <number>;
Alter sequence can change the maxvalue in the sequence
created.
Dropping sequence:
Syntax:
drop sequence <sequenc name> ;
To drop the sequence the DROP command is used
When you use a view, it looks like you’re working with a regular
table, but in reality, the database just runs the query behind the
scenes and gives you the result.
Example :
Types of Indexes:
Syntax :
Syntax :
V2V EdTech LLP | DBMS | Super 25 Questions with Solution
Syntax: