List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:May 14 2003 11:36pm
Subject:Re: Question about auto_increment
View as plain text  
At 13:43 +0100 5/13/03, Tom Gazzini wrote:
>I'm trying to create a table which will form the basis of a database of
>items in a shop. Each item has a category id and an item number. The SQL
>I'm using is this:
>
>DROP TABLE IF EXISTS item;
>CREATE TABLE item
>(
>   cat_id TINYINT UNSIGNED NOT NULL,
>   item_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
>   PRIMARY KEY(cat_id, item_id)
>) TYPE = MYISAM AUTO_INCREMENT = 100000;
>
>('cat_id' points to the primary key of another table called
>'categories')
>
>As you can see, I'm trying to make a composite primary key made of of
>(cat_id, item_id). I'm also trying to produce 6-digit item_id's by using
>the "AUTO_INCREMENT=100000" trick;

This doesn't work for composite keys that include an AUTO_INCREMENT
column, I believe.

>
>However, if I test this using the following SQL:
>INSERT INTO item (cat_id) VALUES (1);
>
>the item_id does starts from 1, instead from 100000.
>
>Can anyone see any reason why this is happening?
>
>Thanks,
>Tom


-- 
Paul DuBois
http://www.kitebird.com/
sql, query
Thread
Load Data Infile from web?CVIOG at UGA7 May
  • Re: Load Data Infile from web?B. van Ouwerkerk7 May
  • RE: Load Data Infile from web?Dathan Vance Pattishall8 May
  • Really too many files opened, help please...ML12 May
    • Re: Really too many files opened, help please...Gustavo A. Baratto13 May
      • Question about auto_incrementTom Gazzini14 May
        • Re: Question about auto_incrementPaul DuBois15 May
  • Re: Really too many files opened, help please...Jerry14 May