-1

I have a database with about 50 tables having data in all but I want to remove those records so the database is like new, is there a way to do this or is there a way to extract the tables without the data?

segawe
  • 35
  • 5
  • Disable foreign key checks. Truncate all tables with according DELETE statements (iterate over INFORMATION_SCHEMA.TABLES, use dynamic SQL). Enable foreign key checks back. – Akina May 11 '21 at 09:16
  • 1
    Another option: backup the database specifying structure only (for example, by mysqldump with --no-data option), also backup procedures/functions/triggers, drop database, restore empty database from the backup. – Akina May 11 '21 at 09:21

1 Answers1

1

You can use DROP command to remove the tables

If you want to keep table schema but delete all records use

TRUNCATE command.

Sakshi Gatyan
  • 1,903
  • 7
  • 13
  • i want to keep the tables but remove every record from each table – segawe May 11 '21 at 08:43
  • Use TRUNCATE command [Link](https://www.javatpoint.com/mysql-truncate-table#:~:text=The%20TRUNCATE%20statement%20in%20MySQL,without%20removing%20the%20table%20structure.) – Sakshi Gatyan May 11 '21 at 08:46