'which is best using delete or truncate when i need to delete all data from table?
I work on sql server 2017
I need to delete all rows from table student_course
but I don't know which is best for use
delete from student_course
OR
truncate table student_course
Tables Structure
table student_course Structure
studentid pk
courseid  pk
table student table
studentid pk
table courses
courseid pk
student_course table have relation with courses table and student table
so which command will be used to delete all rows from table student_course
truncate or delete ?
Solution 1:[1]
I have an foreign key to the table so I will use delete, instead of truncate.
but if i not have forign key then i will use truncate because it faster than delete
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | ahmed barbary | 
