Sql drop and delete | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Sql drop and delete

Delete command delete all record in a table in Sql Database or delete some record when using where clause...Meanwhile drop command remove all record in a table in Sql or remove some records when using ALTER command with DROP...Then what is the real difference between this

24th Nov 2019, 1:30 PM
Cheliyan
Cheliyan - avatar
2 Answers
+ 2
Delete basically deletes the record of table it can be every record or some specific record according to condition that is given. The structure of table remains intact. The table is not deleted only it's data is deleted here. Drop deletes the complete table along with the structure and records. After deleting, the table remains you can use the table again, add data in it but after dropping the table, you cannot use that table because it does not exist in database anymore. So now here, You will have to create that table again if you want to use it. For better Understanding, deletes undoes the insert into command whereas drop undoes the insert as well as the create table command 😅
24th Nov 2019, 1:35 PM
Chetali Shah
Chetali Shah - avatar
0
Just remember that "delete" command is used to remove a particular row from the table according to the given condition. Whereas "drop" command is used to remove the whole table. Also adding to what Chetali Shah said, you can always use (TCL) Transaction Control Language with (DML) Data Manipulation Language commands to save your changes at a particular point by using the SAVEPOINT command and if you by mistake delete a record then you can use a ROLLBACK command to undo the changes. Also remember that you cannot use TCL while creating or dropping tables.
24th Nov 2019, 3:30 PM
Avinesh
Avinesh - avatar