Jump to content


MySQL Clearing


7 replies to this topic

#1 Fernando

    Young Padawan

  • Members
  • Pip
  • 14 posts

Posted 20 July 2005 - 06:58 PM

Can anyone please tell me what is the code to clear out a MySQL Table? I just need it so that when I run the page it will clear the specified Table in the specified database. Thanks.

I looked for the code here on Pixel2Life.com but I did not find it.

#2 wilkesy

    Young Padawan

  • Members
  • Pip
  • 56 posts
  • Location:South Shields UK

Posted 20 July 2005 - 07:01 PM

if u cant find it... try phpMyadmin, im sure you can clear the table in there....

#3 Fernando

    Young Padawan

  • Members
  • Pip
  • 14 posts

Posted 20 July 2005 - 07:03 PM

I checked but I have to delete each row manually and besides, not that I'm being lazy but if I could just run that code without having to log into PhpMyAdmin it would be a lot easier. This is to clear out all my referrers, and I get over 100 hits per day from referrers so every now and then I want to clear it out.

#4 Blitz

    Jedi In Training

  • Twodded Staff
  • PipPip
  • 307 posts
  • Location:California
  • Interests:Php, html, css, etc, band, trumpet, anime, my dog, TV, computers, video games, sleeping, marching band, sleeping, jazz, sleeping, metal, sleeping, classic rock, sleeping, music, jazz band, did I mention sleeping?, kicking the hell out of kids that won't take the time to spell or use proper grammar, my website, etc.

Posted 20 July 2005 - 07:37 PM

If you want to clear everything from one table, just run "DELETE FROM table_name"

#5 Fernando

    Young Padawan

  • Members
  • Pip
  • 14 posts

Posted 20 July 2005 - 07:43 PM

Thank You! That's just what I was looking for :P.

#6 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 21 July 2005 - 12:29 AM

Blitz's code will work just fine, but for future reference:
If you notice, there's more then just one way to delete stuff from phpmyadmin.
You can empty, drop, and truncate tables (not listed). They are the red buttons at the top of the page to the right. Just click the button once, and copy the code it out puts, that simple.
You can also visit the mysql link in the sticky at the top of the page (it give's you every possible command you could want to run in mysql).

#7 adam123

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 2,306 posts
  • Location:London, UK
  • Interests:Programming and stuff.

Posted 21 July 2005 - 01:40 AM

TRUNCATE table_name;

Always works for me.

#8 Wybe

    Jedi In Training

  • Members
  • PipPip
  • 399 posts
  • Gender:Male
  • Location:the Netherlands
  • Interests:Graphic design, digital and traditional, street style, graffiti, guerilla drawing, typography, coding, sex

Posted 23 July 2005 - 04:23 PM

Where you would DELETE everything from a table and still have an empty table left, DROP would leave you with not even the table.

(thatīs an old chinese saying)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users