Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old December 1st, 2003, 01:26 PM
nego nego is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Cracow, POland
Posts: 29 nego User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m
Reputation Power: 0
how to delimit a size of a table

hi

how to delimit a size of a table?
i'd like to have only 100 records

should i delete one with the lowest id
and run update which decrease others id by 1
and the insert new one?

i think that will be very hard to run many task like that
any ideas ?

Reply With Quote
  #2  
Old December 1st, 2003, 01:57 PM
Seadoo Seadoo is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 133 Seadoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: how to delimit a size of a table

You want to have 100 records all the time or just delete old ones from time to time?

In the first case just do
DELETE FROM table where id=min(id);
and then insert the new record.

In the second case:
DELETE FROM table where id<min(id)+100;
And just run the statement from time to time - put it into a file and schedule the program to run every 10 minutes.

Reply With Quote
  #3  
Old December 3rd, 2003, 10:01 AM
Danicek Danicek is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Czech Republic
Posts: 79 Danicek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to Danicek
RE: how to delimit a size of a table

Another sugestion could be to use triger to automaticaly delete oldest row when new row will be inserted and when there is already 100 records in table.

Reply With Quote
  #4  
Old December 3rd, 2003, 11:52 AM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: how to delimit a size of a table

I've seen triggers mentioned in a couple threads lately. MySQL does not have stored procedures of any kind - they are slated to be implemented sometime around version 5.0. Triggers are scheduled for version 5.1. See this page for details.

Reply With Quote
  #5  
Old December 3rd, 2003, 11:56 AM
Danicek Danicek is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Czech Republic
Posts: 79 Danicek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to Danicek
RE: how to delimit a size of a table

Oh, then sorry. I have never worked with mySQL.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > how to delimit a size of a table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway