SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    ********* Scotland Saltire's Avatar
    Join Date
    Jan 2000
    Location
    Scotland
    Posts
    660
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Maximum number of entries

    Hi there,

    I need to be able to set the mysql db I have set up to allow a maximum number of entries of up to 17 rows - how can I do this?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,263
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    create table mytable
    ( id tinyint not null primary key auto_increment
    , foo varchar(9)
    ) auto_increment=111

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    ********* Scotland Saltire's Avatar
    Join Date
    Jan 2000
    Location
    Scotland
    Posts
    660
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is that 111 what I enter to make sure it can only accept 17 rows or is that a generic auto increment number?

    Also, I was just requested that it be changed to 10 rows and not 17.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,263
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    the technique (it's actually more of a hack) relies on the fact that you cannot have a tinyint number greater than 127

    if you want only 10 rows, declare your table with 118 as the auto_increment
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •