Can we use "Delete * from table" to delete all data of table? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Can we use "Delete * from table" to delete all data of table?

20th May 2018, 4:32 PM
Manoj Patidar
Manoj Patidar - avatar
7 Answers
+ 13
Instead use the drop table command Syntax drop tablename;
24th May 2018, 4:23 PM
World Champion
World Champion - avatar
+ 4
to remove all data of table, you only need to write this DELETE FROM table_name ref: https://www.w3schools.com/sql/sql_delete.asp
20th May 2018, 4:48 PM
Amethyst Animion
Amethyst Animion - avatar
+ 3
Yes. if you look up the delete statement here https://www.w3schools.com/sql/sql_delete.asp (or in the individual manuals for specific SQL server flavors), you can see the syntax for DELETE: DELETE FROM table_name WHERE condition; Further down the page, it tells you how to delete all rows. DELETE FROM table_name; or DELETE * FROM table_name; I think this is one of those RTM scenarios, so here are some links to good reference material on SQL: W3 Schools SQL tutorial and reference: https://www.w3schools.com/sql/default.asp MySQL manual: https://dev.mysql.com/doc/refman/8.0/en/
20th May 2018, 4:52 PM
Tavi Kohn
Tavi Kohn - avatar
+ 1
Yes and No. yes you can use delete to eliminate data from a table but if you have an Index and is identity the counter is not restarted. example you have a table and you pk is in 100 if you delete all the data whit the statement delete from tabla and Next you insert a New row the pk contineus whit 101. if you whant yo delete all the data, you need to use Truncate table, this eliminates all the data complety
24th May 2018, 2:44 PM
Edgar Mendoza
Edgar Mendoza - avatar
+ 1
Careful, drop tabla eliminate the table
24th May 2018, 4:25 PM
Edgar Mendoza
Edgar Mendoza - avatar
0
No, you cannot write that. It is because when the statement DELETE FROM TABLE is written, it takes the table as a whole. Moreover, you need to specify a condition to the statement if you want to delete only some specific data.
24th May 2018, 2:56 PM
Debolina Mahapatra
Debolina Mahapatra - avatar
0
Can you do html and pyhone
27th Jun 2018, 11:05 AM
Taym