Postgresql 自增語句,Postgresql增語句

來源:互聯網
上載者:User

Postgresql 自增語句,Postgresql增語句

如果只是簡單地從1開始,遞增值為1,可以這樣寫,serail是一種特殊的類型:


往Employee中添加值及其結果:


如果想設定更加詳細的項,比如起始、遞增值、最大值、最小值,可以定義一個sequence。

在sequence中,如果是no minvalue、no maxvalue表示最小最大值為-1,注意最小值不能大於最大值.。


然後改變表格的列:


往Employee中添加值及其結果:


遞減把increment by屬性值改為負數即可:


往Employee中添加值及其結果:


達到最小值便不可再輸入。

此時表中資料:


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.