BIGSERIAL (8-byte auto-increment pseudo-type)

Last updated: 2026-11-04

BIGSERIAL (8-byte auto-increment pseudo-type)

BIGSERIAL stands to SERIAL as BIGINT stands to INTEGER: it is a pseudo-type made of a BIGINT column plus an auto-increment sequence, covering -9223372036854775808 to 9223372036854775807. It is the right choice once a table is expected to exceed 2.1 billion rows or when primary keys must be merged across databases. Like SERIAL it is not an independent type; the storage type underneath is BIGINT.

Kindtype
Example LanguageSQL

📝 Syntax

BIGSERIAL  |  SERIAL8
--  equivalent to:
--  id bigint NOT NULL DEFAULT nextval('t_bigserial_id_seq')
--  plus an automatically created sequence named t_bigserial_id_seq

Returns:A BIGSERIAL column is physically a BIGINT whose values are handed out by the backing sequence, which starts at 1 and steps by 1.

▶ Example

Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.

Output:

 id | name  | data_type |             column_default
----+-------+-----------+-----------------------------------------
  1 | Alice | bigint    | nextval('t_bigserial_id_seq'::regclass)
  2 | Bob   | bigint    | nextval('t_bigserial_id_seq'::regclass)

📌 Key Points

More case studies coming soon.

📚 Related Reference

❓ FAQ

QDo BIGSERIAL IDs keep increasing?
AYes. The sequence advances monotonically and never wraps, and deleted rows do not free their IDs for reuse. If you need gap-free consecutive numbering, use IDENTITY or maintain the counter yourself.
QCan a BIGSERIAL column be converted to IDENTITY?
ANot with a plain ALTER. The workable path is to add a GENERATED ALWAYS AS IDENTITY column, sync the sequence value over, then drop the old column, or to migrate by rebuilding the table.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏