List:General Discussion« Previous MessageNext Message »
From:Carsten Pedersen Date:December 27 2009 10:10pm
Subject:Re: last_insert_id
View as plain text  
Gary Smith skrev:

...

> An example of where it wouldn't be: Although ID is auto_increment, you 
> could define a row as, say, '10005583429'. This would be a valid input. 
> Selecting max(id) would return that number. However, auto_increment 
> wouldn't change - it would still be '34' (or whatever) for the next 
> line. 

Not quite...

CREATE TABLE t (id bigint unsigned primary key auto_increment);
INSERT INTO t VALUES (10005583429);
INSERT INTO t VALUES (null);
SELECT * FROM t;

+-------------+
| id          |
+-------------+
| 10005583429 |
| 10005583430 |
+-------------+
2 rows in set (0.00 sec)


/ Carsten

Thread
last_insert_idVictor Subervi27 Dec
  • Re: last_insert_idMattia Merzi27 Dec
    • Re: last_insert_idVictor Subervi27 Dec
      • Re: last_insert_idMichael Dykman27 Dec
        • Re: last_insert_idVictor Subervi27 Dec
          • Re: last_insert_idGary Smith27 Dec
            • Re: last_insert_idVictor Subervi27 Dec
            • Re: last_insert_idCarsten Pedersen27 Dec
  • Re: last_insert_idSteve Edberg27 Dec
    • Re: last_insert_idGary Smith27 Dec
      • Re: last_insert_idMark Goodge27 Dec