Home » Mysql » delete all record from table in mysql [closed]

delete all record from table in mysql [closed]

Posted by: admin November 1, 2017 Leave a comment

Questions:

I am trying to delete all records from a table. My query is:

delete from tableName.

But it reports the following error:

Error Code: 1175. You are using safe update mode and you tried to
update a table without a WHERE that uses a KEY column To disable safe
mode, toggle the option in Preferences -> SQL Editor -> Query Editor
and reconnect.”

How do I resolve this?

Answers:

It’s because you tried to update a table without a WHERE that uses a KEY column.

The quick fix is to add SET SQL_SAFE_UPDATES=0; before your query :

SET SQL_SAFE_UPDATES=0; 

Or

close the safe update mode.
Edit -> Preferences -> SQL Editor -> SQL Editor
remove Forbid UPDATE and DELETE statements without a WHERE clause (safe updates) .

BTW you can use truncate table to delete all the records .

Questions:
Answers:

truncate tableName

That is what you are looking for.

Truncate will delete all records in the table, emptying it.