Solved

Deleting all records from a table in PHPMyadmin

Posted on 2009-07-12
7
426 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

707 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

17 Experts available now in Live!

Get 1:1 Help Now