db2
复制代码 代码如下:
create table t1
(
id integer not null generated always as identity (start with 1 increment by 1 minvalue 1 no maxvalue no cycle no cache order ),
…
);
oracle(需要创建一个sequence和一个trigger):
复制代码 代码如下:
create table t1
(
id number(10,0) not null,
…
);
create sequence t1_id_seq increment by 1 start with 1 nomaxvalue nocycle cache 100 order;
create or replace trigger insert_t1_id
before insert on t1
referencing new as new old as old
for each row
begin
select t1_id_seq.nextval into :new.id from dual;
end;
mysql
复制代码 代码如下:
create table t1
(
id int not null auto_increment,
…
);
postgresql
复制代码 代码如下:
create table t1
(
id serial not null,
…
);
sql server
复制代码 代码如下:
create table t1
(
id int not null identity,
…
);
sybase
复制代码 代码如下:
create table t1
(
id int not null identity,
…
);