[RAILS] Delete all records in a MySQL database table

As a memorandum for beginners

Execute the following command to sign in

$ mysql -u root -p

Check the database name with the following command

mysql> SHOW databases;

Move to the database of the table you want to delete

mysql> use [Database name]

If you need to check the table name, execute the following command

mysql> SHOW tables;

Execute the following command after confirming the table name

mysql> TRUNCATE TABLE [table name];

In my case, I was able to delete all the records in the table by the above procedure. If you have a better way, I would appreciate it if you could comment.

Reference site https://qiita.com/nanatsu/items/33b57238b0e9ae0a1c78

Recommended Posts

Delete all records in a MySQL database table
How to clear all data in a particular table
Create a database in a production environment
Java creates a table in a Word document
[Android / Java] Operate a local database in Room
(Ruby on Rails6) Creating data in a table
Stumble in MySQL 5.5-> 5.7
I tried using a database connection in Android development
Delete All from Java SDK in Azure Cosmos DB
How to store Rakuten API data in a table
Create a database of all the books that have been circulating in Japan in the last century