What is difference between TRUNCATE and DELETE statement

Answers were Sorted based on User's Feedback



What is difference between TRUNCATE and DELETE statement..

Answer / nadiya

TRUNCATE DELETE DIFFERENCE

Truncate command will delete all records and the most
important thing to make note of

truncate command is since truncate command cannot be rolled
back one must make
sure to take proper backup of table data before performing
the truncate command.

Truncate command is thus used to remove all rows from
either a table or a cluster.

If one wants to use the truncatecommand in a cluster they
can use
it only in an indexed cluster and not in a hash cluster.


Though the functionality of delete and truncate looks on
the outward same

the main differences between truncate and delete statements
are

truncate is a DDL statement whereas
delete is a DML statement.


Truncate command cannot be rolled back but
delete command can be rolled back.


As a result, as explained

before truncate command is faster than delete command.

Another main difference between delete andtruncate command
is

delete command can be used with a where clause to delete
specific rows from a table.

If the where clause is not specified in a delete
statement,
all rows are deleted from the table.

Thus delete command can be used to delete specific or all
rows from a table.
But truncate command deletes all rows from the table.
The general syntax of truncate command is
TRUNCATE TABLE tablename;
For instance if one wished to truncate a table named as
exforsys
it is done by using the command as follows:


TRUNCATE TABLE exforsys;

Is This Answer Correct ?    0 Yes 1 No

What is difference between TRUNCATE and DELETE statement..

Answer / xyz

truncate basically clears the data from the rows of a
specified colomn.
e.g. truncate colomn_name from table_name
then this will only empty the colomn

delete is used to simpy delete anything from the table.
e.g. delete table_name
this will remove the whole table from the database.

Is This Answer Correct ?    9 Yes 28 No

Post New Answer

More SQL Server Interview Questions

employee table has employee id ----------- empid ---------------- 1 2 3 3 3 4 5 5 5 6 6 6 7 here the values r repeated two times.how to select the repeated values only.i.e 3,5,6 should alone come.

3 Answers  


Why are views required in the sql server or in any other database?

0 Answers  


It is important form e to get the information from log files of applications executed by the task scheduler? Does sql studio save these log files? : sql server management studio

0 Answers  


What is the cpu pressure?

0 Answers  


What is the maximum size of a dimension? : sql server analysis services, ssas

0 Answers  


Explain an incremental backup?

0 Answers  


What is a transaction and why is it important?

0 Answers  


Why should one not prefix user stored procedures with ‘sp_’?

0 Answers  


How to delete an attribute from the emp table

4 Answers  


what are the main differences between ms access and sqlserver

1 Answers   C DAC, CDAC,


can you any body tell me the how to decrease the logfile

4 Answers  


Explain different isolation levels?

4 Answers  


Categories