Solved

Deleting all records from a table in PHPMyadmin

Posted on 2009-07-12
7
427 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
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.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now