Dma Epa
Dma Epa
Ans:
Ans:
SELECT (symbol: σ)
PROJECT (symbol: π)
RENAME (symbol: ρ)
UNION (υ)
INTERSECTION (∩)
Ans:
MySQL
Examination Paper Analysis and Solution
Microsoft SQL Server
SQLite
Oracle Database
Ans:
i) create
ii)drop
iii) alter
iv)rename
v)rename
Q.5 State use of i) Commit and ii) Rollback commands (S-23) 2 Marks
Describe Commit, Rollback and save point with example (S-19) 4 Marks
Ans:
[2 Marks Answer]
i) Commit: It permanently saves all the changes made in the transaction of a database or table.
ii) Rollback : This command restores the database or table to last committed state. It is also used with
SAVEPOINT command to jump to a savepoint in an ongoing transaction.
[4 Marks Answer]
1) Commit:
This command is used to end the transaction and also make its effect permanent to database.
Commit deletes or removes the save points if any.
Syntax:
commit;
(OR)
commit work;
2) Rollback
Syntax:
Examination Paper Analysis and Solution
Rollback;
Rollback to savepoint<savepoint_name>;
Example:
3) Savepoint:
Save points define breakpoints for the transaction to have partial rollback. Save points are treated as
marker to divide lengthy transaction to smaller one.
Syntax:
savepoint<savepoint_name>;
Example:
Savepoint SV1;
Ans:
pattern in a column.
There are two operator often used in conjunction with the LIKE
operator:
Q.2 Describe any two set operators with suitable example. (S-23) 4 Marks
Ans:
Set operators combine the results of two component queries into a single result.
Queries containing set operators are called as compound queries.
Set operators in SQL are represented with following special keywords as: Union, Union all,
intersection & minus.
1) Union: The Union of two or more sets contains all elements, which are present in either or both.
Union works as or. The duplicates of both the tables will appear only once.
Examination Paper Analysis and Solution
e.g. select ename from emp1 union select ename from emp2;
2) Union all: The Union of 2 or more sets contains all elements, which are present in both, including
duplicates.
e.g. select ename from emp1 union all select ename from emp2;
3) Intersection: The intersection of two sets includes elements which are present in both.
e.g. select ename from emp1 intersect select ename from emp2;
4) Minus: The minus of two sets includes elements from set1 minus elements of set2.
e.g. select ename from emp1 minus select ename from emp2;
Q.3 Consider the following schema student (RNO, Name, Course, Percentage) Write SQL commands
for the following : (S-23) 4 Marks
Students.
Ans:
Ii)Display the records having course as ‘cm’ and percentage more than 70.
Ans:
Ans:
Ans:
Q.4 Describe the use of primary key and unique key constraints with example? (W-19) 4 Marks
Ans:
2. Unique Constraint
Examination Paper Analysis and Solution
1. Primary Key constraint: It is use to avoid redundant/duplicate value entry within the row of
specified column in table. It restricts null values too.
Syntax:
(column_name datatype(size),
Example:
2. Unique Constraint: The UNIQUE constraint uniquely identifies each record in a database table.
The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column
or set of columns.
syntax:
(column_name data_type,
constraint_name unique);
Example:
firstname varchar2(20),
city varchar2(20));
Q.5 Write any two types of join with example of each? ( W-19) 4 Marks
Ans:
Examination Paper Analysis and Solution
1)Inner Join: An INNER JOIN is a type of SQL join that combines rows from two tables based on a
related column, including only the rows where there is a match.
For example:
ON employees.DepartmentID = departments.DepartmentID;
This query retrieves a list of employees and their department names, combining data from the
employees and departments tables based on the common DepartmentID column. The result
includes only rows with matching DepartmentID values in both tables.
Output :
2)Left Join :
A LEFT JOIN is a type of join operation in relational databases that returns all rows from the
left table and the matched rows from the right table.
If there is no match, NULL values are returned for columns from the right table.
This type of join is useful when you want to retrieve all records from the left table and include
matching records from the right table.
Let's consider an example with two tables: employees and departments. The employees table
contains information about employees, including their employee_id, employee_name, and
department_id. The departments table contains information about different departments, including
department_id and department_name.
The result of the LEFT JOIN will include all rows from the employees table and matching rows from
the departments table.
Examination Paper Analysis and Solution
If there is no match, NULL values will be displayed for columns from the departments table.
Output:
employee_id employee_name department_id department_name
1 John 101 HR
2 Jane 102 IT
3 Bob 101 HR
4 Alice 103 Finance
In this example, you can see that all employees are included in the result, and the department_name
is displayed if there is a match.
If there is no match (e.g., employee with employee_id 4 in department 103), NULL values are
displayed for the columns from the departments table.
3)Right Join
A right join, also known as a right outer join, is a type of SQL join that returns all the rows from the
right table (table2) and the matched rows from the left table (table1). If there are no matches, NULL
values are returned for the columns from the left table.
Output:
EmployeeID Name DepartmentName
1 John HR
2 Alice IT
3 Bob NULL
NULL NULL Finance
In the output:
John and Alice have departments (HR and IT, respectively), so their information is displayed
along with their department names.
Bob doesn't have a department assigned (NULL in the DepartmentID column), so his
department information shows as NULL.
Examination Paper Analysis and Solution
Mary's information is included from the Employees table, even though there is no
corresponding department information for her in the Departments table. This is because of the
right join, which includes all rows from the right table (Departments) regardless of whether
there is a match in the left table (Employees).
Let's consider two tables, employees and departments, and we want to perform a full outer join
based on the department_id column. Here are the example tables: Table: employees
employee_id employee_name department_id
1 John 101
2 Jane 102
3 Bob 103
4 Alice 101
Table: departments
department_id department_name
101 HR
102 IT
104 Finance
Q.6 Describe Group by and Having clause with suitable example (S-23) 4 Marks
Ans:
Group by: -
It is used to group rows that have the same values. The grouping can happen after retrieval of rows
based on a certain condition.
Syntax: -
select statements...
Example: -
group by gender;
Having clause: -
Syntax:
select statements...
group by column_name1[,column_name2,...]
[having condition];
Example: -
select branch,max(per)
from student
group by branch;
Q.7 Consider the Schema Emp (E.NO, E. Name, Department, Salary, Bonus).
Ans:
ii) Display all records having a salary between 5000 and 10000.
Ans:
where Salary
Ans:
iv) Display E.No., E.Name and total payment (i.e. Salary and Bonus) of all employees
Ans:
i) Create department table with suitable data type and size of each attribute.
Ans:
DNO number(5),
DName varchar2(25),
Location varchar2(20),
Manager varchar2(30)
);
Examination Paper Analysis and Solution
ii) Add one more attribute as Ph-no with suitable data type.
Ans:
Ans:
(OR)
DName varchar2(25),
Location varchar2(20),
Manager varchar2(30)
);
ii) Display all records from product relation having 'v' anywhere in the P name.
Ans:
select * from Product where PName like ‘%v%’;
iii) Display S No., P. No., Qty, and S Name using tables Supplier and Shipment.
Ans:
(or)
iv) Display S No., P No., P Name using the relations Product and Shipment.
Ans:
(or)
selectShipment.SNo, Product.PNo. Product.PName
from Product join Shipment
on Shipment.PNo = Product.PNo ;
v)Display all records from product having price more than 2000.
Ans:
select PNo, PName,Price from Product where Price>2000;
(OR)
vi) Display S Name and Location from Supplier having location as 'Mumbai'.
Ans:
select SName, Location from Supplier where Location
=’Mumbai’;
Subquery is a select statement that is embedded in a clause of another SELECT statement i.e.
nesting of queries or query within query.
Types of subqueries
1) Single row subqueries
2) Multiple row subqueries
3) Multiple column subqueries
Single row subqueries: A single row subquery is one that returns one
row from inner SELECT statement. This type of subquery uses single
row operators = , > , >= , < , <= , < >
Syntax:
SELECT column_name1… column_name n
FROM <table_name>
WHERE column1 operator
(SELECT column from table_name where condition);
Example :
Display the employee details whose job title is the same as that of employee 1005.
Select empno,ename,job,salary,deptno
From emp
Where job=(select job from emp where empno=1005);
Multiple row subqueries: Subqueries that return more than one roware called multiple-row
subqueries. Multiple row operators are used instead of a subquery, with a multiple row subquery.
Operator Meaning
In Equal to any member in the list.
Examination Paper Analysis and Solution
Any Compare value to each value returned by the
subquery.
All Compare value to every value returned by the
subquery.
Syntax:
FROM table_name
example
Find the employees who earn the same salary as minimum salary for departments.
Select empno,ename,job,salary,deptno
From emp
Queries that return the values from more than one column are called multiple column subqueries.
syntax:
FROM table_name
Example: Display the name, department number, salary and commission of any employee whose
salary and commission matches both the commission and salary of any employee in department 10
Query:
Select empno,deptno,salary,comm
From emp
i) Display student’s rollno, name, and marks of both subjects for all Students.
Ans:
marks.sub1_marks, marks.sub2_marks
ii)Delete all those students records who secured less than 35%
Ans:
Ans:
Ans:
employee{empid,empname,designation,salary,deptno}
dept { deptno,deptname,location}
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
The SQL BETWEEN clause allows user to easily test if an expression is within a range of
values (inclusive). The values can be text, date, ornumbers.
It can be used in a SELECT, INSERT, UPDATE, or DELETE statement. The SQL BETWEEN
Condition will return the records where expression is within the range of value1 and value2
inclusive of the the values.
Ans:
1.initcap(str)
Example:
2. lower(str)
Example:
Example:
4. length(str)
Example:
5.ltrim(str)
Example:
6. rtrim(str)
Example:
7. Lpad(char1,length,char2)
characters in char2.
Example:
8. Rpad(char1,length,char2)
Examination Paper Analysis and Solution
It returns char1, right-padded to given length
Example
Example:
10. Replace(char,searchstring,[repstring])
Example:
11. Substr(char,m,n)
of length n
Example:
Example:
Examination Paper Analysis and Solution
13. Chr(n)
14. Ascii(char)
Q17. Describe GRANT and Revoke with its syntax and example.(S-19) 4 Marks
Ans:
Grant:
Syntax:
grant option] ;
Example:
Revoke:
This command is used to withdraw the privileges that has been granted to a user.
Syntax:
from <username> ;
Examination Paper Analysis and Solution
Example:
(i) Find customer name having saving account as well as loan Account.
Where d. Cust_name=b.cust_name;
(ii) Fine customer names having loan account but not the savings account.
Ans:
minus
Where d. Cust_name=b.cust_name;
(i) Create the table as named 'student' with field as roll no, name, address, DOB and percent.
Ans:
(rollno number(5),
name char(20),
address varchar2(40),
Examination Paper Analysis and Solution
DOB date,
percent number(5,2)
);
Ans:
Ans:
(iv) Remove/ delete the data or records from student info table.
Ans:
OR
student (roll_no, name, city, marks, result). Write queries for the following:
Ans:
Ans:
Ans:
Ans:
Q.21 Describe system and object privileges and also describe use of Grant and Revoke commands
with suitable example.(W-19) 4 Marks
Ans:
System Privileges: System privileges are privileges given to users to allow them to perform certain
functions that deal with managing the database and the server.
Object Privileges:
Object privileges are privileges given to users as rights and restrictions to change contents of
database object – where database objects are things like tables, stored procedures, indexes, etc.
e.g.
Grant:
This command is used to give permission to user to do operations on the other user’s object.
Syntax:
on <object name> to
Example:
Revoke:
granted to a user.
Examination Paper Analysis and Solution
Syntax:
<username> ;
Example:
Ans:
Definition:
Synonym is an alternative name for database object, referred to as the database object that can exist
on a local or remote server.
Use:
Synonyms are used mainly to make it easy for users to access database objects owned by other
users.
They hide the underlying object's identity and make it harder for a malicious program or user to
target the underlying object.
Q3. Write a command to create and drop synonym of any relation. (S-23,W-19) 4 Marks
Ans:
Ans:
Start with 10
Examination Paper Analysis and Solution
Increment by 10
Minvalue 10
Maxvalue 100;
Q5. Describe the use of Index and write command to create an Index.(S-23)
Ans:
Indexing is used to optimize the performance of a database by minimizing the number of disk
accesses required when a query is processed.
• The index is a type of data structure. It is used to locate and access the data in a database table
quickly.
• For example, if you want to reference all pages in a book that discusses a certain topic, you first
refer to the index, which lists all the topics alphabetically and is then referred to one or more specific
page numbers.
Creating an Index:
Syntax:
ON TABLE column;
where the index is the name given to that index and TABLE is the name of the table on which that
index is created and column is the name of that column for which it is applied.
Definition of index:
Characteristics of index:
1. It can reduce disk i/o by using a rapid path access to locate data quickly.
2. Indexes are logically and physically independent of the table they index.
Emp
Ans:
Ans:
Ans:
Ans
as select <query>;
OR
table_nameWHERE [condition];
Ans:
Syntax:
Create sequence<seq_name>
OR
Sequence is a set of integers 1, 2, 3 … that are generated and supported by some database
systems to produce unique values on demand.
A sequence is a user defined schema bound object that generates a sequence of numeric
values.
Sequences are frequently used in many databases because many applications require each
row in a table to contain a unique value and sequences provides an easy way to generate
them.
The sequence of numeric values is generated in an ascending or descending order at defined
intervals and can be configured to restart when max_value exceeds.
OR
Sequence:
It is database object that generate/produce integer values in sequential order.
It automatically generates primary key and unique key values.
It may be ascending or descending order
It can be used for multiple tables.
Sequence numbers are stored and generated independently of tables
Q8. Create Sequence seq-1 with starting value 1 and maximum value 20
with an increment of 1. Consider schema Customer (custno,
custname, telephone) and use seq-1 for inserting a row in customer
Table.(W-19) 4 Marks
Ans:
Create Sequence seq-1
Start with 1
Increment by 1
Minvalue 1
Maxvalue 20;
Ans:
e.g.:
Create index on employee (empno);
e.g.:
Create index on employee (ename, empno);
3) Unique indexes are used not only for performance, but also for data integrity. A unique index does
not allow any duplicate values to be inserted into the table.
Syntax :
Create unique index index_name on table_name(column_name);
e.g:
Create unique index index_empno on emp(empno);
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.
Ans:
Insert into person (personid) values (seq_pid.nextval);
Ans:
Create view person as select * from person where city=’Mumbai’
or city=’Pune’;
Q11. Create synonyms for class tables.Write steps to create synonyms. (S-19) 4 Marks
The following code shows how to create a synonym for the class table
Ans:
The following code shows how to create a synonym for the class table
Example:
Syntax:
synonym_name
Q12. Create sequence for department table and also altered the created sequence.(S-19) 4 Marks
Ans:
Start with 1
Increment by 1
Maxvalue 100;
Example: -
The following program will update the table and increase the salary of each customer by 500 and use
the SQL%ROWCOUNT attribute to determine the number of rows affected −
DECLARE
total_rows number (2);
BEGIN
UPDATE customers
SET salary = salary + 500;
IF sql%notfound THEN
dbms_output.put_line('no customers selected');
ELSIF sql%found THEN
total_rows:= sql%rowcount;
dbms_output.put_line( total_rows|| ' customers selected ');
END IF;
END;
Explicit cursors:
They are programmer-defined cursors for gaining more control over the context area. An explicit
cursor should be defined in the declaration section of the PL/SQL Block. It is created on a
SELECT Statement which returns more than one row.
OPEN c_customers;
CLOSE c_customers;
Q4. Write a PL/SQL program to find the largest of three numbers. (S-23) 4 Marks
Ans:
declare
a number;
b number;
c number;
begin
dbms_output.put_line('Enter a:');
a: =&a;
dbms_output.put_line('Enter b:');
b: =&b;
dbms_output.put_line('Enter c:');
c: =&c;
if (a>b) and (a>c)
Then
dbms_output.put_line('A is GREATEST'||a);
elsif (b>a) and (b>c)
then
dbms_output.put_line('B is GREATEST'||b);
else
dbms_output.put_line('C is GREATEST'||c);
end if;
end;
Q5. Create a trigger which invokes on updation of record in Department table.(S-23) 6 Marks
Ans:
create trigger trigger_update
on department
after update
as
begin
select * from department;
end;
Q6. i) Write a function to find area of a circle and call the function.
ii) Create a stored procedure to accept name and greet user with name. (S-23) 6 Marks
Ans:
i)
Function Creation
SQL>create or replace function circle_area (radius in number) return
number as
pi constant number:= 3.14;
area number;
begin
Examination Paper Analysis and Solution
area:= pi * radius *radius;
return area;
end circle_area;
Function Calling
begin
dbms_output.put_line(circle_area(3));
end;
(OR)
SQL>declare
r number;
ans number;
begin
r: =&r;
ans:=circle_area(r);
dbms_output.put_line(“radius=” ||r);
dbms_output.put_line(“Area of circle ="||ans);
end;
ii) Stored procedure to accept name and greet user with name.
create or replace procedure Greet_User (user_name in varchar2)
is
begin
dbms_output.put_line(“Greet” || user_name);
end;
Q7. Explain steps of cursor implementation with syntax and example. (W-23) 4 Marks
Ans:
Cursor: it is temporary work area created in system memory when SQL statement is exceuted .
Types of Cursors:
Implicit Cursor
Explicit Cursor
Example:
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;
Examination Paper Analysis and Solution
CLOSE c_customers;
END;
Q.8 Write a PL/SQl program to display 10 reverse numbers. Use for loop. (W-23) 4 Marks
Ans:
DECLARE
a number (2);
BEGIN
FOR a IN REVERSE 1 .. 10 LOOP
dbms_output.put_line('value of a: ' || a);
END LOOP;
END;
Q9. Write PL-SQL program which accepts the customer ID from the user, if user enter an invalid ID,
then the exception invalid_id is raised using exception handling. (W-23) 6Marks
Ans:
DECLARE
c_id customers.id%type := &cc_id;
c_name customerS.Name%type;
c_addr customers.address%type;
ex_invalid_id EXCEPTION;
BEGIN
IF c_id <= 0 THEN
RAISE ex_invalid_id;
ELSE
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
WHEN ex_invalid_id THEN
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!');
END;
Output:
Q10. write PL-SQL code to print largest number from three numbers (accept three numbers from
user). (W-23) 6Marks
Ans:
declare
a number: =&a;
b number: =&b;
c number: =&c;
Examination Paper Analysis and Solution
begin
dbms_output.put_line('a='||a||' b='||b||' c='||c);
if a>b AND a>c
then
dbms_output.put_line('a is greatest');
else
if b>a AND b>c
then
dbms_output.put_line('b is greatest');
else
dbms_output.put_line('c is greatest');
end if;
end if;
end;
Output:
a=10 b=12 c=5
b is greatest
From the above block, declare and exception blocks are not compulsory block.
Whereas begin and end blocks are compulsory block.
If executable statements from begin consisting of any error, then that error will be handled in
exception block.
PL/SQL is not case-sensitive
Q.13 Write a PL/SQL code that accepts 3 numbers from user and display largest number. (W-
22)4Marks
Ans:
declare
a number: =&a;
b number: =&b;
c number: =&c;
begin
dbms_output.put_line('a='||a||' b='||b||' c='||c);
Examination Paper Analysis and Solution
if a>b AND a>c
then
dbms_output.put_line('a is greatest');
else
if b>a AND b>c
then
dbms_output.put_line('b is greatest');
else
dbms_output.put_line('c is greatest');
end if;
end if;
end;
Output:
a=10 b=12 c=5
b is greatest
Q.14 Define cursor. Write step by step syntax to declare, open, fetch and close cursor in PL/SQL
block. (W-22)4 Marks
Ans:
Cursor: it is temporary work area created in system memory when SQL statement is exceuted .
Types of Cursors:
Implicit Cursor
Explicit Cursor
Example:
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;
Q.15.Write a PL/SQL code that handles divide by zero exception. (W-22) 4 Marks
Ans:
declare
a number (5): = 10;
b number (5): =0;
Examination Paper Analysis and Solution
c number (5);
myex EXCEPTION;
begin
c: =a/b;
if b=0 then
raise myex;
end if;
dbms_output.put_line(c);
EXCEPTION
when myex then
dbms_output.put_line('divide by zero exception occurred');
end;
Output:
divide by zero exception occurred
DECLARE
CURSOR c
IS SELECT * FROM emp where deptno=dept_no;
TYPE emp_tab IS TABLE OF c%ROWTYPE INDEX BY BINARY_INTEGER;
v_emp_tab emp_tab;
BEGIN
OPEN c;
FETCH c BULK COLLECT INTO v_emp_tab;
DBMS_OUTPUT.PUT_LINE(v_emp_tab.COUNT);
CLOSE c;
END;
END;
Examination Paper Analysis and Solution
To execute procedure
exec emp_count(10);
Q3. Describe the different types and causes of Database failure. (S-23) 4 Marks
Ans:
1. Hardware Failure/System crash:
There is a hardware malfunction that causes the loss of the content of volatile storage, and it brings
transaction processing to a halt. The content of non-volatile storage remains intact and is not
corrupted or changed.
2. Software Failure:
The database software or the operating system may be corrupted or fail to work correctly, that may
cause the loss of the content of volatile storage, and results in database failure.
3. Media Failure:
A disk block loses its content as a result of either a head crash or failure during a data transfer
operation.
4. Network Failure:
A problem with network interface card or network connection and cause network failure.
5. Transaction Failure
i) Logical error: the transaction can no longer continue with its normal execution because of some
internal condition, such as wrong input values, data not found, data overflow or resource limit
exceeded.
ii) System error: A system entered in state like deadlock
6. Application software Error:
The problem with software accessing the data from database. -This may cause database failure as
data cannot be updated using such application to it. -Logical errors in the program cause one or more
transaction failures.
7. Physical disaster
The problem was caused by floods, fire, earthquakes etc.
Q4. Describe different states of transaction with a neat diagram (S-23) 4 Marks
Ans:
Examination Paper Analysis and Solution
Q7. Describe use of grant and revoke commands with suitable example. (W-23) 4Marks
Examination Paper Analysis and Solution
Ans:
Grant: This command is used to give permission to the user to do operations on the other user’s
object.
Syntax: Grant <object privileges> on <object name> to <username> [with grant option];
Example: Grant select, update on emp to user1;
Revoke: This command is used to withdraw the privilege that has been granted to a user.
Syntax: Revoke <object privileges> on <object name> from <username>;
Example: Revoke select, update on emp from user1;
Q9. Define database backup. Describe how database backup helps to avoid failures. (W-23) 4 marks
Ans:
Database backup: Database Backup is storage of data that means the copy of the data.
It is a safeguard against unexpected data loss and application errors.
It protects the database against data loss.
If the original data is lost, then using the backup it can reconstructed The
backups are divided into two types:
1. Physical Backup
2. Logical Backup
1. Physical backup: Physical Backups are the backups of the physical files used in storing and
recovering your database, such as data files, control files and archived redo logs, log files. It is a copy
of files storing database information to some other location, such as disk, some offline storage like
magnetic tape.
2.Logical backup: Logical Backup contains logical data which is extracted from a database. It
includes backup of logical data like views, procedures, functions, tables, etc.
Database backup helps to avoid failures in following way:
In case any kind of failure strikes your SQL server databases, a proper plan and a way of
recovery from that failure is needed, beforehand. A good backup can indeed be the best way
to recover from most of the failures, especially when your data is too critical or important.
In case you lose a database or any of the tables becomes corrupt, then you can simply reload
your data from the backup. In addition, if you lose the whole server, then you may need to set
up a new server and re-install the SQL Server backup software, before using any of your
backups.
Examination Paper Analysis and Solution
One of the most effective ways to prevent any kind of data loss and to recover your original
data in case of any failure is to store your entire SQL server database off-site. A secure
offshore backup can save you from many serious hassles in
Q10. Create a trigger which invokes on updating of record on emp table (W-23) 4 Marks
Ans:
create trigger trigger_update on emp
after update as
begin
Select * from employee;
end;
end;
Q13. Define transaction and explain ACID properties of transaction. (W-22) 4Marks
Ans:
Transaction:
Any logical work or set of work that is done on the data of a database is known as a transaction.
1. Atomicity
Atomicity is based on the concept that each transaction be “all or nothing”: if any one part of the
transaction in a sequence fails, then the entire transaction fails, and there will be no change in
database state.
This property states that, either all operations contained by a transaction are done successfully or
none of them complete at all. To maintain the consistency of data this property is very useful.
2. Consistency
The consistency property ensures that the transaction executed on the database system will bring the
database from its original consistent state to another.
3. Isolation
Examination Paper Analysis and Solution
The isolation property ensures that the system state should be same that would be obtained if
transactions were executed sequentially, i.e., one after the other. The effect of any incomplete
transaction should not be visible to other transactions. This can be achieved by isolation.
4. Durability
The durability property ensures that after the transaction is committed successfully the updates made
should remain permanent in the database even in the event of power loss, crashes or errors.
iii) Remove INSERT and DELETE privileges on book table from Rajesh.
REVOKE INSERT, DELETE ON book FROM Rajesh;