You are on page 1of 1

1. What is difference between TRUNCATE & DELETE Ans: TRUNCATE is a DDL command and cannot be rolled back.

All of the memory space is released back to the server. DELETE is a DML command and can be rolled back. Both commands accomplish identical tasks (removing all data from a table), but TRUNCATE is much faster. While database is in full recovery mode, it can rollback any changes done by DELETE using Log files. TRUNCATE can not be rolled back using log files in full recovery mode. DELETE and TRUNCATE both can be rolled back when surrounded by TRANSACTION if the current session is not closed. If TRUNCATE is written in Query Editor surrounded by TRANSACTION and if session is closed, it can not be rolled back but DELETE can be rolled back 2. What is the use of INDEX? Ans: Indexes allow the database application to find data fast; without reading the whole table. Syntax: CREATE INDEX PIndex ON Persons (LastName, FirstName). 3. Different between Where Clause and Having Clause. Ans: Having clause is used to filter group while WHERE CLAUSE is used to filter rows. Having clause can have aggregate function but WHERE CLAUSE Cannot have aggregate function. HAVING CLAUSE is used for evaluating a condition with an aggregate function, i.e., GROUP BY whereas WHERE CLAUSE is used for general conditions.

You might also like