List:General Discussion« Previous MessageNext Message »
From:Johan De Meersman Date:April 22 2010 9:11am
Subject:Re: Auto Increment in InnoDB
View as plain text  
You can't, iirc - if you add an autoincrement to InnoDB it MUST be the
primary key.

You *can*, however, add that, set it as PK and stick a unique index on
(cluster, file) instead. Behaviour will be identical, but be aware that
there will be some performance implications - you will now have to do an
extra primary key lookup every time you select based on the (cluster,file)
key.


On Thu, Apr 22, 2010 at 7:03 AM, Aveek Misra <aveekm@stripped> wrote:

> I have a InnoDB table which contains columns named 'cluster' and 'file'
> ('cluster' + 'file' is a primary key). I want to add a new column that
> tracks the revision number of a file for a given cluster and a file. The
> situation is tailor made for a MyIsam table where I can add a new Auto
> Increment column as a secondary column in a multiple column index. How can I
> get the same behavior in an InnoDB table? Given below is a view of how the
> records will look like
>
> --------------------------------------------------------
> | Cluster             |    File                |   Rev       |
> --------------------------------------------------------
> | clusterA           |   fileA               |   1            |
> --------------------------------------------------------
> | clusterA           |   fileA               |   2            |
> ---------------------------------------------------------
> | clusterB           |   fileA               |   1            |
> --------------------------------------------------------
> | clusterB           |   fileB               |   1            |
> --------------------------------------------------------
>
>
>
> Thanks
> Aveek
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
>


-- 
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel

Thread
Auto Increment in InnoDBAveek Misra22 Apr
  • Re: Auto Increment in InnoDBJohan De Meersman22 Apr
    • Re: Auto Increment in InnoDBAveek Misra22 Apr
      • Re: Auto Increment in InnoDBJohan De Meersman22 Apr
        • Re: Auto Increment in InnoDBAveek Misra22 Apr
          • Re: Auto Increment in InnoDBJohan De Meersman22 Apr
            • Re: Auto Increment in InnoDBAveek Misra22 Apr
              • Re: Auto Increment in InnoDBJohan De Meersman22 Apr
            • Re: Auto Increment in InnoDBCarsten Pedersen22 Apr
              • Re: Auto Increment in InnoDBJohan De Meersman22 Apr
                • Re: Auto Increment in InnoDBChris W22 Apr
                  • Re: Auto Increment in InnoDBJohan De Meersman23 Apr
  • Re: Auto Increment in InnoDBmos22 Apr