what is the diffrence between truncate and delete in sql server?

后端 未结 3 827
遥遥无期
遥遥无期 2021-01-18 09:46

Can anybody provide me the list of all the differences between truncate and delete in SQL server?

3条回答
  •  无人及你
    2021-01-18 10:08

    You should google it before asking.

    Truncate

    1. Truncate removes all the references from database.
    2. Fast
    3. No entry in transaction log.
    4. Cannot be recovered if removed once.
    5. Page refrences are cleared.
    6. All or none
    7. Identity column gets re-initialized to seed
    8. Truncate is DDL

    Truncate Table tblName

    No contidion can be given

    Delete

    1. Entries are made at Transaction log.
    2. Recoverable
    3. Slow
    4. Per record based deletion
    5. References are mainained in page
    6. Identity starts from its previous position
    7. DML
    Delete FROM tableName
    

    None of the two effects any structure to table. All references must be removed before performing any of the operation, although it doesn't applies to delete when used with Cascade = true for delete

提交回复
热议问题