Friday, October 12, 2012

Difference between delete and truncate using screenshots.

1) DELETE Cannot deallocate the page space.using this command we cannot clear the data.

   TRUNCATE Clears the page data.it will deallocate the page space.


1st diff




















2) TRUNCATE will resets the identity on a table.DELETE will not reset the identity on table



































3) TRUNCATE is faster than DELETE Command





































4) TRUNCATE is DDL command where as DELETE is DML command.


    Syntax: DELETE FROM TABLENAME i.e like select * from table
   
                TRUNCATE TABLE TABLENAME i,e create table TABLENAME (name varchar(10))
         
5) DELETE can apply on specific rows where as TRUNCATE cannot.


6) TRUNCATE cannot use when there is key constraint on a table.

    DELETE can apply using DELETE Cascade.




   




No comments: