The document outlines key concepts and topics related to Database Management Systems (DBMS), including data models, manipulation languages, and database design principles. It also includes previous year question papers from Punjab Technical University, covering various aspects of database architecture, query processing, and security. Additionally, it discusses advanced topics such as distributed databases and concurrency control techniques.
The document outlines key concepts and topics related to Database Management Systems (DBMS), including data models, manipulation languages, and database design principles. It also includes previous year question papers from Punjab Technical University, covering various aspects of database architecture, query processing, and security. Additionally, it discusses advanced topics such as distributed databases and concurrency control techniques.
Now let us delete the INSTRUCTOR tablo using DROP TABLE statement.
SQL > DROP TABLE INSTRUCTOR.
29
ssary to remove table from a database completely or you
RENAMING Tables : Oracle provides the facility to change the name of the table by using a
ALTER TABLE statement, when you rename the table, oracle automatically updates foreign keys in
the data dictonary but it does't update a stored code modules, storéd queries or reports client applications
so care must be taken when renaming the tables.
Syntax ALTER TABLE
RENAME TO to
To remove the INSTRUCTOR table to TEACHER, the statement is
SQL> ALTER TABLE INSTRUCTOR
RENAME TO TEACHER;
OR
SQL > RANAME INSTRUCTOR TO TEACHER;
oracle.
Q 45. What is the rollback of database ? Explain the process with a1
n example from
(PTU, May 2014)
Ans. The Roll back statement is used to undo all the changes that the user-has made to the
database since the last commit statement was issued or since the database session begins which
ever is later. If you havé complete a series of insert, update or delete statements but have not yet
explicitly or implicitly committed them and you encounter a problem such as computer failure, oracle
will automatically roll back ariy uncommitted work. The synatx is :
SQL > Rollback;
Consider a DEPARTMENT table using two columns 'DEPT_ID' and ‘DNAME® containing
departments ID and name of the department respectively. Initially the table consists of two rows as
shown below: r
Dept_id DNAME
T COMPUTER
2 ENGLISH
SQL > COMMIT;
‘SQL > INSERT into Departmemnt values (3, ‘Math’;
1 row created. : .
SQL > insert into Department values (4, ‘commerce’
1 row created,
+ SQL> ROLLBACK;
Roliback Complete, é
SQL > Select * from Departemt;
Dept_id DNAME
7 COMPUTER
2 ENGLISH
Now let us insert two rows in the DEPARTMENT tabie using INSERT statement.TT
03D) Database Manageme, q
_30 jes have been rolleg back
Noy
It will display the origional table with onh
execute the following statement : ‘Math’);
'SOL = INSERT into Department values (3,'Math);
1 row created, c jerce’);
SOL INSERT into Department values (4 ‘Comm
T row created :
SQL > COMMIT; .
Commit complete
SQL > insert into Departe
‘1 row created
SQL > Rollback;
Roll back complete.
two rows as chan
mnt values (5, Hind!)
‘SQL > Select * from Department; ~
DeptD. DNAME.
1 ‘COMPUTER
2 ENGLISH
3 MATH
4 COMMERCE Be
SAVE POINT?A SAVEPOINT allows you tocreate marked point with a transaction. You ma
¢ point without rong back any of the work that precededy
rollback your transaction to that marke i ale ah
SAVEPOINT's are a useful transaction failure since they allow you to divide a single large transacian
into a series of smaller parts. While all the stétements executed are still part ofthe larger transact,
roll them back as if they were a single statement,
you can group certain statements together and a
“Anyother prior statements in the transactions are unaffected: You may have multiple SAVEPOINTS
in a single transaction. . e
The Syntax is
‘SQL > SAVEPOINT ;
Where is the name given to a savepoint. :
To selectively ROLL BACK a group of ‘statements within a large transaction use the ROLLBACK
TO Now let is again consider the DEPARTMENT table.
SQL> INSERT INTO Department values (5, 'HINDI');
1 rowcreated
SQL > SAVEPOINT ABC;
Savepoint created;
SQL > INSERT INTO DEPARTMENT VALUES (6, ‘History’);
1 rowcreated
SQL > ROLLBACK TO ABC; *
Roll back Complete, |
SQL > Select * form DEPARTMENT ;
Deptid |. DName
COMPUTER
ENGLISH
MATH :
COMMERCE
HINDI
anon