# PGSQL 的序列需要自定义

**URL:** <https://www.isharkfly.com/t/pgsql/18440>\
**Category:** 数据库\
**Tags:** postgresql\
**Created:** [November 17, 2025, 2:25pm UTC](https://www.isharkfly.com/t/pgsql/18440 "2025-11-17T14:25:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hex](https://www.isharkfly.com/user_avatar/www.isharkfly.com/hex/32/21953_2.png) [@hex](https://www.isharkfly.com/u/hex)\
**Post date:** [November 17, 2025, 2:25pm UTC](https://www.isharkfly.com/t/pgsql/18440/1 "2025-11-17T14:25:43Z")

</div>

与 MySQL 可以在表上直接定义序列不同， PGSQL 的序列需要自行定义。

 ![2025-11-17_09-22-26](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/3X/0/8/08fc0c46edd445035dbbc43337f544c4a483f677.jpeg)

通常会导致有多少个表就至少需要定义多少自增序列。

不过，Oracle 也采用的是这个方式。
