7 Replies - 936 Views - Last Post: 09 October 2012 - 10:12 AM

#1 clee06  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 66
  • Joined: 01-June 10

How to delete all the rows in a table

Posted 09 October 2012 - 09:41 AM

Hey guys, what is the code to delete all the records(rows) in a table? I only know the drop table 'table_name' command.
Is This A Good Question/Topic? 0
  • +

Replies To: How to delete all the rows in a table

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,788
  • Joined: 12-June 08

Re: How to delete all the rows in a table

Posted 09 October 2012 - 09:47 AM

You can use 'DELETE' with no 'where' clause..
https://dev.mysql.co.../en/delete.html

or.. truncate.
https://dev.mysql.co...cate-table.html
Was This Post Helpful? 0
  • +
  • -

#3 clee06  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 66
  • Joined: 01-June 10

Re: How to delete all the rows in a table

Posted 09 October 2012 - 09:50 AM

So i can do something like:

DELETE FROM "table_name"



... and it will clean my table?

Nevermind I tried it and it works. Thank you!

This post has been edited by clee06: 09 October 2012 - 09:52 AM

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,788
  • Joined: 12-June 08

Re: How to delete all the rows in a table

Posted 09 October 2012 - 09:51 AM

Yup... what happens when you run it?
Was This Post Helpful? 0
  • +
  • -

#5 clee06  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 66
  • Joined: 01-June 10

Re: How to delete all the rows in a table

Posted 09 October 2012 - 10:00 AM

View Postmodi123_1, on 09 October 2012 - 09:51 AM, said:

Yup... what happens when you run it?


empty out my table, but my column name still exists.

This post has been edited by clee06: 09 October 2012 - 10:01 AM

Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,788
  • Joined: 12-June 08

Re: How to delete all the rows in a table

Posted 09 October 2012 - 10:02 AM

Well.. yeah. That's the point - it deletes the rows. Why would you need it to delete the columns as well?
Was This Post Helpful? 0
  • +
  • -

#7 clee06  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 66
  • Joined: 01-June 10

Re: How to delete all the rows in a table

Posted 09 October 2012 - 10:10 AM

View Postmodi123_1, on 09 October 2012 - 10:02 AM, said:

Well.. yeah. That's the point - it deletes the rows. Why would you need it to delete the columns as well?


haha no that is all.

I was trying to empty out the table and read a new set of records in it.
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,788
  • Joined: 12-June 08

Re: How to delete all the rows in a table

Posted 09 October 2012 - 10:12 AM

Yup.. delete is fine but if you get in to giant quantities of data you may find 'truncate' works a bit faster.. but's a whole mess of data.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1