+ 12
What is the difference between Truncate, Drop and Delete statement?
6 Réponses
+ 4
delete means delete selected or particular entries from table like using where clause. truncate is use to delete all entries from table. and drop is use to destory table from database
+ 2
(I assume you work on tables)
Truncate deletes all rows of a table leaving the table empty in your database
Delete deletes rows who matches your WHERE statement (can also be used for deleting all rows if you leave the Where out but is much slower)
Drop removes the whole table with all rows and columns
Usage:
Truncate for deleting every entry in a table because you want to keep the structure but want to start over
Delete for individual delete requests if a single user wants to delete his second email etc
Drop if you not only want to delete the entries but the whole table because you have a better idea how to structure your data in a new table
+ 1
Delete is a DML command in sql and drop is DDL command and truncate is also DDL command but the difference between truncate and drop is that if you drop a table than the table will deleted from the database but if you write truncate table name than structure of table will remain in the your database
That's the main difference among these three commands
0
drop means to remove the database table as well as delete is to delete the table
0
- drop command is used to remove a table from the database.
- truncate command is used to delete the data inside a table, but not the table itself.
- delete is used to delete the existing records from a table.
0
drop means remove all contents in your database.
delete means. delete only you selected.