If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > A Question of MySQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-06, 22:04
rogers2006 rogers2006 is offline
Registered User
 
Join Date: Jan 2006
Posts: 1
A Question of MySQL

hello everyone,

i real need you help! i wanna create a table with a strict number of rows!
i have tried option MAX_ROWS, but that is in vain. i do not know how to do it, now! Thank you!
Reply With Quote
  #2 (permalink)  
Old 01-08-06, 07:54
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
what number?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-10-06, 10:07
John Grubb John Grubb is offline
Registered User
 
Join Date: Jan 2006
Posts: 27
Not sure why you'd want to do that. A DB is not supoosed to enforce something like that.

If this is a v5, you should be able to put a trigger on it, or you could load the table and jigger the permissions so noone has insert permissions.

To suggest a method, kinda need to know WHY you want this

Jay Grubb
Technical Consultant
OpenLink Software
Web: http://www.openlinksw.com:
Product Weblogs:
Virtuoso: http://www.openlinksw.com/weblogs/virtuoso
UDA: http://www.openlinksw.com/weblogs/uda
Universal Data Access & Virtual Database Technology Providers
Reply With Quote
  #4 (permalink)  
Old 01-11-06, 08:58
SQL Maestro SQL Maestro is offline
Registered User
 
Join Date: Jan 2006
Posts: 1
This is a piece of my old code. I used it against fake download counter.
DB should be filled for required records quantity with blank data before using.

Quote:
CREATE TABLE Hits (
Hit int(10) NOT NULL default '0',
Program smallint(6) unsigned NOT NULL default '0',
Expiration_Date int(10) NOT NULL default '0',
PRIMARY KEY (Hit,Program),
KEY Program (Program),
KEY Expiration_Date (Expiration_Date)
) TYPE=MyISAM MIN_ROWS=100 MAX_ROWS=100 PACK_KEYS=1 ROW_FORMAT=FIXED;
MIN_ROWS and MAX_ROWS have no sense at all. only for appearance... :-)


PHP Code:
          if($hits_count)
          {
            
$query='SELECT 1 FROM `Hits` WHERE `Hit`='.$user->ip.' AND `Program`='.$this->program['Program'].' LIMIT 1';
            
$r=&$db->query(&$query);
            if(!
$db->num_rows(&$r))
            {
              
$query='SELECT `Hit`,`Program` FROM `Hits` ORDER BY `Expiration_Date` LIMIT 1';
              
$r=&$db->query(&$query);
              list(
$hit,$program)=$db->fetch_row(&$r);
              
$db->free_result(&$r);

              
$query='UPDATE `Hits` SET `Hit`='.$user->ip.',`Program`='.$this->program['Program'].',`Expiration_Date`='.time().' WHERE `Hit`='.$hit.' AND `Program`='.$program.' LIMIT 1';
              
$db->query(&$query);
              
$query='UPDATE `Programs` SET `Real_Hits_Count`=`Real_Hits_Count`+1 WHERE `Program`='.$this->program['Program'].' LIMIT 1';
              
$db->query(&$query);
            }
          } 
...there I'm using 'update' instead 'insert'....


Regards
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On