Avatar of andieje
andieje asked on

why can't you have composite primary keys containing autoinc in InnoDB

Hi

For MyISAM and BDB tables you can have an auto_increment field as a secondary part of key, e.g.

CREATE TABLE foo (
   id          INT AUTO_INCREMENT NOT NULL,
   group_field INT NOT NULL,
   name        VARCHAR(128),
 
   PRIMARY KEY(group_field, id)
);
Here's what the manual says about this

In this case, the generated value for the AUTO_INCREMENT column is calculated as MAX(auto_increment_column) + 1 WHERE prefix=given-prefix. This is useful when you want to put data into ordered groups.

Why can't you do this in InnoDB. What's the best way to emulate this in innodb if its even possible.

thanks
MySQL Server

Avatar of undefined
Last Comment
andieje

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Guy Hengel [angelIII / a3]

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
andieje

would you be so kind as to look at this question for me

https://www.experts-exchange.com/Database/MySQL/Q_26654652.html#a34277675
ASKER
andieje

thanjks
Your help has saved me hundreds of hours of internet surfing.
fblack61