Eliminar todos los registros en una tabla de MYSQL en phpMyAdmin


Uso wampserver 2.2. Cuando quiero eliminar todos los registros de una tabla en phpMyAdmin (seleccionar todo) elimina solo un registro no todos los registros. ¿Por qué no elimina todos los registros?

Author: Amirhosein Heydari, 2013-08-16

8 answers

Vaya a su estructura db -> y vacíe en la tabla requerida. Ver aquí:

esta captura de pantalla

 106
Author: Yalamber,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-13 05:52:16

Tienes 2 opciones delete y truncate :

  1. delete from mytable

    Esto eliminará todo el contenido de la tabla, no reseteando el autoincremental id, este proceso es muy lento. Si desea eliminar registros específicos, agregue una cláusula where al final.

  2. truncate myTable

    Esto restablecerá la tabla, es decir, todos los campos incrementales automáticos se restablecerán. Es un DDL y es muy rápido. No puede eliminar ningún registro específico a través de truncate.

 131
Author: Sashi Kant,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-05 04:32:54

Vaya a la pestaña Sql ejecute una de las siguientes consultas:

delete from tableName;

Eliminar : eliminará todas las filas de la tabla. El siguiente inserto tomará el siguiente id de incremento automático.

O

truncate tableName;

Truncate : también eliminará las filas de su tabla, pero comenzará desde una nueva fila con 1.

Un blog detallado con un ejemplo: http://sforsuresh.in/phpmyadmin-deleting-rows-mysql-table /

 116
Author: Suresh Kamrushi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-11-02 08:30:32

Utilice esta consulta:

DELETE FROM tableName;

Nota: Para eliminar algún registro específico, también puede dar la condición en la cláusula where en la consulta.

O puede utilizar esta consulta también:

truncate tableName;

También recuerde que no debe tener ninguna relación con otra tabla. Si habrá alguna restricción de clave externa en la tabla, entonces esos registros no se eliminarán y darán el error.

 24
Author: Code Lღver,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-08-16 11:12:14

Puede eliminar todas las filas con este comando.Pero recuerde una cosa que una vez que utilice el comando truncate no puede revertirlo.

  truncate tableName;
 14
Author: Ravi Kumar Ravanam,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-07 11:58:40

'Truncate tableName' fallará en una tabla con restricción de clave definida. Tampoco reindexará el valor de la tabla AUTO_INCREMENT. En su lugar, Elimine todas las entradas de la tabla y restablezca la indexación a 1 usando esta sintaxis sql:

DELETE FROM tableName;
ALTER TABLE tableName AUTO_INCREMENT = 1
 10
Author: DevWL,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-24 23:35:20

Un hecho interesante.

Estaba seguro de que TRUNCATE siempre funcionará mejor, pero en mi caso, para una base de datos con aproximadamente 30 tablas con claves foráneas, pobladas con solo unas pocas filas, tomó aproximadamente 12 segundos TRUNCAR todas las tablas, en lugar de solo unos pocos cientos de milisegundos para ELIMINAR las filas. Establecer el incremento automático agrega aproximadamente un segundo en total, pero aún así es mucho mejor.

Así que sugeriría probar ambos, ver cuál funciona más rápido para su caso.

 4
Author: Sorin,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-02-17 12:19:13

Escriba la consulta: trunca 'Your_table_name';

 1
Author: Shadman Sakib,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-03 10:59:11