Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.1k views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...