postgresql 設置字段的自動增長


以前使用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('','');


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM