postgreSQL 自动递增序号

创建表格

 CREATE TABLE test
 ( id serial,
 name varchar(16) not null
 );

查询当前创建好的表格

插入数据

BEGIN TRANSACTION;
INSERT INTO test(name)  VALUES('A0001');
commit;

再次查询表格,ID为1

插入第二条数据,序号自动为2

BEGIN TRANSACTION;
INSERT INTO test(name) VALUES('A0002');
commit;

重复第二步操作

 未完待续…

猜你喜欢

转载自www.cnblogs.com/siyun/p/10223035.html