Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delete all from table

what's faster?

DELETE FROM table_name; 

or

DELETE FROM table_name where 1=1; 

why?

does truncate table work in access?

like image 698
Alex Gordon Avatar asked Jun 08 '10 20:06

Alex Gordon


People also ask

How delete all data from column in SQL table?

Right-click on the table and go to Design. It shows all column of a particular table. Right-click on the left-hand side of a column and you get option Delete Column. Click on it to delete a column.

Which command is used to remove all rows from a table?

The truncate command removes all rows of a table.


2 Answers

This should be faster:

DELETE * FROM table_name; 

because RDBMS don't have to look where is what.

You should be fine with truncate though:

truncate table table_name 
like image 23
Sarfraz Avatar answered Oct 04 '22 16:10

Sarfraz


You can use the below query to remove all the rows from the table, also you should keep it in mind that it will reset the Identity too.

TRUNCATE TABLE table_name 
like image 185
Jaymz Avatar answered Oct 04 '22 17:10

Jaymz