Solved

Deleting all records from a table in PHPMyadmin

Posted on 2009-07-12
7
429 Views
Last Modified: 2012-05-07
Seeking step-by-step instructions to delete all records in a table called MyTable.  Thanks!
0
Comment
Question by:BBRRGG
7 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 200 total points
ID: 24837186
if there is no relations u just need to use

TRUNCATE TABLE MyTable

otherwise you need to delete the recods for the related table then delete from this table
delete from relatedTable where foreignKey in (select primaryKey from MyTable)
delete from MyTable
0
 
LVL 2

Assisted Solution

by:SadiDev
SadiDev earned 100 total points
ID: 24837900
There is two query to do this job:
1) DELETE FROM table_name
2) TRUNCATE TABLE table_name

First one only delete the records, you can use it with WHERE clause too.
The second one will delete all the records and reset the auto id/number fields.

There is a tab named (labeled) 'Empty' in MyPHPAdmin. It will do the same task as TRUNCATE TABLE command.

Thank you
Sadi
0
 
LVL 2

Expert Comment

by:SadiDev
ID: 24837913
Oh! One more thing about DELETE and TRUNCATE TABLE :
DELETE command delete the records individually; but TRUNCATE TABLE command erase all the records at once.

Thank you
Sadi
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 13

Assisted Solution

by:Philip Pinnell
Philip Pinnell earned 50 total points
ID: 24839212
In phpMyAdmin on the database view (list of tables) click the bin on the table you want to empty.

This runs the truncate table command as mentioned above. Also pay heed to the related records comment above too.
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 24839222
sorry sadi you already said that.
0
 

Author Closing Comment

by:BBRRGG
ID: 31602705
Thanks!
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 24863343
thanks
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can > be used for a Text field 6 49
SSRS Enable Remote Errors 4 26
Email not working after mx record created 8 11
average of calculation (TSQL) 4 6
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question