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 ),
…
);
(
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;
(
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,
…
);
(
id int not null auto_increment,
…
);
postgresql
复制代码 代码如下:
create table t1
(
id serial not null,
…
);
(
id serial not null,
…
);
sql server
复制代码 代码如下:
create table t1
(
id int not null identity,
…
);
(
id int not null identity,
…
);
sybase
复制代码 代码如下:
create table t1
(
id int not null identity,
…
);
(
id int not null identity,
…
);
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/dtteaching/803023.html