Re: [PHP] clear a mysql table
Jim Lucas a écrit : I would ass-u-me that if someone had foreign keys and/or triggers setup that they would not need to ask how to clear/empty a table I never assume that kind of thing, because he could be cleaning a database he didn't designed. It happends. :) -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear a mysql table
Lupus Michaelis wrote: > Daniel P. Brown a écrit : >> In direct response to your question, you're looking for the >> TRUNCATE command. > > I hope he doesn't have any foreign keys nor triggers. > I would ass-u-me that if someone had foreign keys and/or triggers setup that they would not need to ask how to clear/empty a table -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear a mysql table
Daniel P. Brown a écrit : In direct response to your question, you're looking for the TRUNCATE command. I hope he doesn't have any foreign keys nor triggers. -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear a mysql table
> > > truncate cash; > Hey, my wife does that all the time! -- Bastien Cat, the other other white meat
Re: [PHP] clear a mysql table
Ronald Wiplinger (Lists) wrote: I need to clear a table (cache) from a database based on the database size. Our web site uses cached pages. Our webhost only allow us 100 MB storage. Usually the database is just 10 MB, but when a search engine crawls our calendar, then the storage is quickly 108 MB. The system reports then mathematically correct: Space left on database -8MB !!! I plan therefore a web page, which is triggered by cron every hour and will just clear the table. Can I use just: mysql_query("DELETE FROM cash") or die(mysql_error()); If you really want to delete all rows, use truncate cash; otherwise the db deletes the entries row by row - which will be slow, and also it has to update all indexes on the tables as it is doing it. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear a mysql table
On Sat, 2008-10-25 at 20:47 -0500, Micah Gersten wrote: > > Ronald Wiplinger (Lists) wrote: > > I need to clear a table (cache) from a database based on the database size. > > > > Our web site uses cached pages. Our webhost only allow us 100 MB > > storage. Usually the database is just 10 MB, but when a search engine > > crawls our calendar, then the storage is quickly 108 MB. The system > > reports then mathematically correct: Space left on database -8MB !!! > > > > I plan therefore a web page, which is triggered by cron every hour and > > will just clear the table. > > > > Can I use just: > > mysql_query("DELETE FROM cash") > > or die(mysql_error()); > > > > > > or do I need to loop through all records? or is there a better solution? > > > > How can I get the database size? > > > > bye > > > > R. > > > > > Perhaps you should not have search engines index your calendar. > > Thank you, > Micah Gersten > onShore Networks > Internal Developer > http://www.onshore.com > > Yeah, you seem to be trying to treat the effect rather than the cause, which will more than likely have other problems down the road. Are you sure you need to cache calendar pages too? I mean, if you look at the web stats for your site, is it really benefiting from caching in the calendar section? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear a mysql table
Ronald Wiplinger (Lists) wrote: > I need to clear a table (cache) from a database based on the database size. > > Our web site uses cached pages. Our webhost only allow us 100 MB > storage. Usually the database is just 10 MB, but when a search engine > crawls our calendar, then the storage is quickly 108 MB. The system > reports then mathematically correct: Space left on database -8MB !!! > > I plan therefore a web page, which is triggered by cron every hour and > will just clear the table. > > Can I use just: > mysql_query("DELETE FROM cash") > or die(mysql_error()); > > > or do I need to loop through all records? or is there a better solution? > > How can I get the database size? > > bye > > R. > > Perhaps you should not have search engines index your calendar. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear a mysql table
I used to have a similar problem What I did was to define a max number of cashed pages. So when reaching that number I simply did it the FIFO way -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear a mysql table
On Sat, Oct 25, 2008 at 11:02 AM, Ronald Wiplinger (Lists) <[EMAIL PROTECTED]> wrote: > > I plan therefore a web page, which is triggered by cron every hour and > will just clear the table. > > Can I use just: > mysql_query("DELETE FROM cash") > or die(mysql_error()); Please remember that GOOGLE is your friend, so STFW before asking here. Also, note that there's a specific list for database issues, PHP-DB --- http://php.net/mailinglists In direct response to your question, you're looking for the TRUNCATE command. -- http://www.parasane.net/ [New Look] [EMAIL PROTECTED] || [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear a mysql table
> or is there a better solution? Yes, look for a better hosting firm. 100Mb is paltry these days. -- Richard Heyes HTML5 Graphing for FF, Chrome, Opera and Safari: http://www.rgraph.org (Updated October 25th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear a mysql table
At 11:02 PM +0800 10/25/08, Ronald Wiplinger (Lists) wrote: Can I use just: mysql_query("DELETE FROM cash") or die(mysql_error()); If you need to delete some cash, please look in my direction. :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] clear a mysql table
I need to clear a table (cache) from a database based on the database size. Our web site uses cached pages. Our webhost only allow us 100 MB storage. Usually the database is just 10 MB, but when a search engine crawls our calendar, then the storage is quickly 108 MB. The system reports then mathematically correct: Space left on database -8MB !!! I plan therefore a web page, which is triggered by cron every hour and will just clear the table. Can I use just: mysql_query("DELETE FROM cash") or die(mysql_error()); or do I need to loop through all records? or is there a better solution? How can I get the database size? bye R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php