# 审查表元数据中的序列定义

> 使用 \\d+ 对比序列转换前后的表 Default 定义。

---

LLMS 索引： [llms.txt](/zh/llms.txt)

---

> Snowflake 2.6.1 上游参考。Mimus 19.0.1 已整合的 pgEdge 扩展为 [Spock 5.0.15](/zh/docs/spock/)；Snowflake 在 Mimus 上的兼容性尚待验证。

转换序列之前，在 psql 中用 `\d+ orders` 查看表的元数据，`Default` 列会显示 PostgreSQL 序列定义。

```sh
acctg=# \d+ orders;
                                                             Table "public.orders"
  Column  |       Type        | Collation | Nullable |              Default               | Storage  | Compression | Stats target | Description 
----------+-------------------+-----------+----------+------------------------------------+----------+-------------+--------------+-------------
 customer | character varying |           |          |                                    | extended |             |              | 
 invoice  | character varying |           |          |                                    | extended |             |              | 
 id       | bigint            |           | not null | nextval('orders_id_seq'::regclass) | plain    |             |              | 
Indexes:
    "orders_pkey" PRIMARY KEY, btree (id)
Access method: heap
```

执行转换后，`\d+ table_name` 命令显示的 `Default` 值为 `snowflake.nextval('orders_id_seq'::regclass)`：

``` sh
acctg=# \d+ orders
                                                                  Table "public.orders"
  Column  |       Type        | Collation | Nullable |                   Default                    | Storage  | Compression | Stats target | Descripti
on 
----------+-------------------+-----------+----------+----------------------------------------------+----------+-------------+--------------+----------
---
 customer | character varying |           |          |                                              | extended |             |              | 
 invoice  | character varying |           |          |                                              | extended |             |              | 
 id       | bigint            |           | not null | snowflake.nextval('orders_id_seq'::regclass) | plain    |             |              | 
Indexes:
    "orders_pkey" PRIMARY KEY, btree (id)
Access method: heap
```

---

[上游原文](https://github.com/pgEdge/snowflake/blob/9506e1bd5c1f8f8c22df43bdc3efd2b00398ddd8/docs/review_seq.md) · `9506e1bd5c1f` · Copyright (c) 2023–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL 许可证](/zh/docs/spock/upstream/about/license/)。

中文译校：PGSTY 社区。

[PG.CENTER 双语底本](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/snowflake/review-seq.zh.md)

---

反链：

- [Snowflake](/zh/docs/spock/upstream/snowflake/)
