Original Tweet From @freest_man
I went through SQL 156 question bank and sat for 5 interviews
Here is the most frequently asked
What is the difference between DELETE, DROP and TRUNCATE?
Take a moment to think of the possible answer before continuing
1/ DELETE
It is a Data Manipulation Language (DML) command.
It can delete all rows or certain rows under conditions using WHERE.
DELETE cannot delete the structure of the table.
ie The column names still exist but with empty rows.
We can restore the deleted rows using the ROLLBACK command.
AdSpace Here!!
2/ DROP
It is a Data Definition Language (DDL) command.
With the help of DROP it can delete the entire table along with its structure.
ROLLBACK command cannot restore the dropped table.
By using DROP the existence of the whole table is gone.
AdSpace Here!!
3/ TRUNCATE
It is also a Data Definition Language (DDL) command.
TRUNCATE can only delete all the rows from the table in one go.
It cannot be used with the WHERE command.
It is faster than the DELETE command.
Here we cant restore the values using ROLLBACK.
That's a wrap!
AdSpace Here!!
If you enjoyed this thread:
- Follow me @freest_man for more of these
- RT the tweet below to share this thread with your audience https://twitter.com/1562857893958823936/status/1591075118389657601
Click Here For More Posts Like This https://www.knowledge-twitter.com
Top comments (0)