0

I know that we cannot use where clause with truncate..But i want to delete some records in a table by keeping other records as usual by using truncate...

Can we do that??

Anup
  • 144
  • 1
  • 7
  • 2
    delete only.... – krishn Patel Mar 29 '17 at 10:20
  • No, you should use `delete` for that – Stefano Zanini Mar 29 '17 at 10:21
  • `truncate` and `delete` have in common the fact that they delete data. However, `delete` does it row-by-row, and so you can qualify it with a `where` clause. `truncate` is, I believe, classified as a DDL statement (Data Definition Language) and affects the table as a whole. Among other things, I can be used to reset any auto-increments. So the answer is no. – Manngo Mar 29 '17 at 10:28

1 Answers1

2

No, TRUNCATE is all or nothing. You can do a DELETE FROM <table> WHERE <conditions> but this loses the speed advantages of TRUNCATE.

This thread is a good read :)

Community
  • 1
  • 1
Muhammad Qasim
  • 1,622
  • 14
  • 26