In this tutorial, you will learn how to write SQL delete statement and SQL truncate statement
Here we learn the difference between Delete and Truncate in SQL
Delete statement will delete data from Table, delete statement can be written with where clause.
Let's take a look at the SQL Delete example
delete from tbTeacher //or you can write delete from tbTeacher where teacherId = 1 // Write some insert statement insert into tbTeacher (FullName, Address, Contactnumber, Updatedon) Values ('Some Name','Some Address', '9000000', getdate()) // Select * from tbTeacher
Notice in above screenshot: every time you execute a delete statement on a table and then keep inserting new records again and again, the index value will be automatically incremented for new records
Let's take a look at the SQL Truncate example
Truncate table tbTeacher //you cannot write Truncate table tbTeacher where teacherId = 1
Notice in above screenshot: every time you execute a truncate statement on a table and then keep inserting new records again and again, the index value will NOT be incremented for new records, it will always starts from one.
NOTE: Like Delete Statement you can NOT use WHERE clause with Truncate statement.