MySQL equivalent of Oracle's SEQUENCE.NEXTVAL

前端 未结 7 1374
无人及你
无人及你 2020-12-01 11:13

I need to be able to generate run a query that will return the next value of ID on the following table:

CREATE TABLE animals (
     id MEDIUMINT NOT NULL AUT         


        
7条回答
  •  既然无缘
    2020-12-01 11:38

    You could add your own MySQL function - as demonstrated at http://www.microshell.com/database/mysql/emulating-nextval-function-to-get-sequence-in-mysql/ - allowing you to do something like this:

    SELECT nextval('sq_my_sequence') as next_sequence;
    

提交回复
热议问题