Delete all records in MYSQL table in phpMyAdmin

I am using wampserver 2.2. When I want to delete all records of a table in phpMyAdmin (select all), it will delete only one record of not all records. Why doesn't he delete all entries?

+79
mysql wampserver
Aug 16 '13 at 11:09 on
source share
8 answers

Go to the db → structure and make an empty value in the desired table. See here:

this screenshot

+92
Aug 16 '13 at 11:15
source share

You have 2 options for delete and truncate :

1) delete from mytable : This will delete the entire contents of the table, and not the registry auto-increment identifier, this process is very slow. If you want to delete specific entries, add a where clause at the end.

2) truncate myTable : This will reset the table, that is, all automatic incremental fields will reset. This is DDL and very fast. You cannot delete any specific entry through truncate

+109
Aug 16 '13 at 11:12
source share

Click the Sql tab by doing one of the following queries:

 delete from tableName; 

Delete : will delete all rows from your table. The next insert will accept the next auto increment identifier.

or

 truncate tableName; 

Truncate : will also delete rows from your table, but it will start from a new row at 1.

A detailed blog with an example: http://sforsuresh.in/phpmyadmin-deleting-rows-mysql-table/

+97
Aug 16 '13 at 11:13 on
source share

Use this query:

 DELETE FROM tableName; 

Note. To delete a specific entry, you can also specify a condition in the where clause of the request.

OR you can also use this query:

 truncate tableName; 

Also remember that you should not have any relationship with another table. If there is any foreign key restriction in the table, this record will not be deleted and will give an error.

+22
Aug 16 '13 at 11:12
source share

You can delete all rows with this command. But remember one thing: when you use the truncate command, you cannot undo it.

  truncate tableName; 
+10
Aug 05 '16 at 13:08 on
source share

"Truncate tableName" will fail in a table with a key restriction set. It will also not override the value of the AUTO_INCREMENT table. Instead, delete all table entries and reset the indexing back to 1 using this sql syntax:

 DELETE FROM tableName; ALTER TABLE tableName AUTO_INCREMENT = 1 
+7
Aug 18 '16 at 18:59
source share

Interesting fact.

I was sure that TRUNCATE would always work better, but in my case for db with about 30 tables with foreign keys filled with just a few rows, it took about 12 seconds to TRUNCATE all the tables, not just a few hundred milliseconds, to DELETE rows . Setting auto increment adds about a second, but still much better.

Therefore, I would suggest to try both, to see what works faster for your business.

+4
Feb 17 '14 at 12:19
source share

write a request: truncate 'Your_table_name';

+1
Mar 03 '17 at 10:59 on
source share



All Articles