PostgreSQL MySQL 兼容性之 - 自增值

AUTO_INCREMENT , sequence

MySQL

  AUTO_INCREMENT 
    The AUTO_INCREMENT attribute can be used to generate a unique identity for new rows. 
    When you insert a new record to the table, and the auto_increment field is NULL or DEFAULT, the value will automatically be incremented. 
    This also applies to 0, unless the NO_AUTO_VALUE_ON_ZERO SQL_MODE is enabled.

PostgreSQL

  serial4
  create table test(id serial4);
    or
  serial8
  create table test(id serial8);
    or
  create sequence seq;
  create table test(id int default nextval('seq'::regclass));

你可能感兴趣的:(PostgreSQL MySQL 兼容性之 - 自增值)