Sql: Difference between truncate and delete command

Hi friends,

what is the difference between delete and trancate command

Replies

  • Kaustubh Katdare
    Kaustubh Katdare
    babloo0311
    Hi friends,

    what is the difference between delete and trancate command
    Its 'truncate', I think.
  • manupep
    manupep
    Is there any command 'delete' ?
    I think 'drop table' is the command used to delete one table.
    'truncate' will delete only the contents of the table . The table structure should remain. we can add datas further.
  • Prasad Ajinkya
    Prasad Ajinkya
    Well, you can also use delete from command to delete only the contents of the table. Schema will remain intact though.
  • manupep
    manupep
    oh! yes 'delete' is there to delete rows according to condition.
  • shalini_goel14
    shalini_goel14
    Hi Babloo

    1. TRUNCATE : You can't use WHERE clause
    DELETE : You can use WHERE clause

    2. TRUNCATE : You can't use WHERE clause
    DELETE : You can use WHERE clause

    3. Delete - delete deletes the records from table it can be rollbacked also you can give the where condiition to it.
    Truncate - delete all records from table There is no rollback it always commit without giving the commit command

    TRUNCATE is a DDL command and cannot be rolled back and All of the memory space is released back to the server. It can not use the Where conditions. DELETE is a DML command and can be rolled back. here can be use where conditions. TRUNCATE is much faster but don not use it if delete can work.
  • babloo0311
    babloo0311
    yeah thanks buddy
  • manupep
    manupep
    oh! so much infos .Thanks shalini.
  • shalini_goel14
    shalini_goel14
    Always welcome ๐Ÿ˜€ .

    Sorry for Duplicate points:

    1. TRUNCATE : You can't use WHERE clause
    DELETE : You can use WHERE clause

    2. TRUNCATE : You can't use WHERE clause
    DELETE : You can use WHERE clause
  • babloo0311
    babloo0311
    yeah no probs
  • Prasad Ajinkya
    Prasad Ajinkya
    Wow! Good tips Shalini!!
  • zia.sepsis
    zia.sepsis
    Truncate table does not support the Where clause. In addition, the Truncate table statement does not fire a trigger. When truncate is used, the deleted rows are not entered in the transaction log. there fore it can't be rolled back. when the delete command is used , it creates a transaction log file which help you in the process of rollback.
    the syntax of truncate statement is:-
    truncate table table_name
    the syntax of delete statement is:-
    delete table_name

    both the statements is used to delete all the records form the table
    correct me if am wrong ๐Ÿ˜
  • HEART-HACKER
    HEART-HACKER
    I think you got your ANS ๐Ÿ˜

You are reading an archived discussion.

Related Posts

Happy b'day ๐Ÿ˜๐Ÿ˜๐Ÿ˜๐Ÿ˜๐Ÿ˜ Happy birthday to CE ๐Ÿ˜๐Ÿ˜๐Ÿ˜๐Ÿ˜ ๐Ÿ˜๐Ÿ˜ ๐Ÿ˜ waiting for CE (with new look)
hello friends iam harika...iam doing my btech 3rd yr i need some help in selecting my mini project can any one help....... plz its urgent
Hey guys...I am Aditya, I am studying B.tech 2nd year in electronic and communication. I've just now completed my 1st semester, but there is no practical knowledge gain.. I mean...
Dont get panic about viruses...jus try this to avoid viruses through USB..๐Ÿ˜Ž AFTER YOU PLUG IN THE USB,DONT ALLOW IT TO AUTO PLAY.CLICK THE CANCEL BUTTON. 2.GO TO MY COMPUTER...
๐Ÿ˜’ can any one suggest how would it be if i make-up my mini project on spam filters (bayseian) in java language............