-1

I am trying to empty the database of any data, while keeping the relationships and tables as they are

I have no idea if my thinking is right or wrong

3 Answers3

0

Yes, you just run mysqldump with --no-data

mysqldump --no-data -u someuser -p mydatabase

You can save it to a .sql file and then drop your database Then you restore it from the dump

0
truncate table_name;

table_name is the table you want to delete all data in it. truncate only works on tables, so you need to execute truncate table one by one.

npe
  • 34
  • 3
  • I have to cancel the relationships between the tables, and I have too many tables, and it will take me a long time to cancel and link the relationships again – Khaled Ahmed Nov 24 '22 at 07:44
0

Use truncate to all table :

mysqldump -d -uuser -ppass --add-drop-table databasename > databasename.sql
mysql -uuser -ppass databasename < databasename.sql

or you can read this, similar problem.