Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL Autoincrement InnoDB like MyISAM
    primarykey
    data
    text
    <p>MyISAM allows very convenient way to create serials. E.g. In the table primary key is id+seq(-uence)</p> <pre><code>id seq 1 1 insert into table(seq) values(1),(2),(3),(1),(2),(1),(1),(2); 1 2 1 3 2 1 2 2 3 1 4 1 4 2 </code></pre> <p>So logic is when id remains the same untill appears duplicate key, in this case (MyISAM) will increment id.</p> <p>But when I try use it in InnoDB - doesn't work. Is there a workaround (because I need transactions)?</p> <p>Thanks.</p> <p>May be better example from comments to Manual of MySQL Posted by [name withheld] on October 23 2003 8:41pm</p> <pre><code>create table location ( id bigint not null auto_increment, -- "serial" per 4.1 longitude int, latitude int, place int, primary key(id, longitude, latitude, place) ); insert into location (longitude, latitude, place) values (0,0,0), (1,1,1), (2,2,2); select * from foo; +----+-----------+----------+-------+ | id | longitude | latitude | place | +----+-----------+----------+-------+ | 1 | 0 | 0 | 0 | | 2 | 1 | 1 | 1 | | 3 | 2 | 2 | 2 | +----+-----------+----------+-------+ drop table location; create table location ( id bigint not null auto_increment, -- "serial" per 4.1 longitude int, latitude int, place int, primary key(longitude, latitude, place, id) ); insert into location (longitude, latitude, place) values (0,0,0), (1,1,1), (2,2,2), (0,0,0); select * from location order by id; +----+-----------+----------+-------+ | id | longitude | latitude | place | +----+-----------+----------+-------+ | 1 | 0 | 0 | 0 | | 1 | 1 | 1 | 1 | | 1 | 2 | 2 | 2 | | 2 | 0 | 0 | 0 | +----+-----------+----------+-------+ </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload