PostgreSQL自增语法

mysql使用auto_increment的语法实现表字段自增。
在PostgreSQL中,具有数据类型为smallserial,serial,bigserial的字段具有自增特性。

create table company(
	id serial primary key,
	name text not null,
	age int not null,
	address char(50),
	salary real
);

则在插入该表的时候,可以不插入id列,数据库系统会自动填充。

insert into company(name,age,address,salary) values('huangbaokang',29,'ganzhou',100000);

猜你喜欢

转载自blog.csdn.net/huangbaokang/article/details/88868069
今日推荐