以前使用mysql 設置自動增長的語句如下
create table person(id int not null primary key auto_increment);
mysql是用auto_increment這個屬性來標識字段的自增,在使用insert 語句時候id 這個字段的值可以寫 ''或NULL
postgresql 使用序列來標識字段的自增長
CREATE TABLE daodaoimg
(
id serial NOT NULL,
alttext text,
imgurl text
)
直行這條語句后 會自動生成daodaoimg_id_seq這個序列
insert 語句的時候可以不加id這個字段 insert into daodaoimg(alttext,imgurl) values('','');