Mysql中建立序列的方法,mysql建立序列

來源:互聯網
上載者:User

Mysql中建立序列的方法,mysql建立序列

CREATE TABLE emp_seq ( seq VARCHAR(8));INSERT INTO emp_seq VALUES('0');UPDATE emp_seq SET seq = LAST_INSERT_ID(seq+1);SELECT LAST_INSERT_ID();


這東西完全跟oracle的sequence一致。即使在update之後,select之前有其它session也update了,本session得到的,仍然是自己update的那一個值。


上面的語句在orcle中是這樣子寫的。

create sequence emp_seq start with 1 increment by 1; 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.