How can I delete the contents of all tables in my database in phpMyAdmin without dropping the database?

后端 未结 10 1378
予麋鹿
予麋鹿 2021-02-13 03:32

How can I empty the contents of all tables in my database in phpMyAdmin without dropping any of the tables in the database?

Since I do this several times an hour while i

10条回答
  •  渐次进展
    2021-02-13 04:00

    The TRUNCATE TABLE statement will empty a table completely (MySql 3.23 and above).

    You can create a script that you can reuse for a particular database. It's not generic but saves you from creating a new database + login each time you want to start with a fresh db.

    Here's how to create a script yourself: In your webbrowser go to phpMyAdmin and select the database. Click the SQL tab and execute 'SHOW TABLES'. Choose the printerfriendly format and copy the contents to a text editor.

    Now for each table name you re-write it in the format:

    TRUNCATE TABLE ;
    

    note: You can use a regular expression if you have many tables

提交回复
热议问题