跳转到主要内容

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

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

Snowflake 2.6.1 上游参考。Mimus 19.0.1 已整合的 pgEdge 扩展为 Spock 5.0.15;Snowflake 在 Mimus 上的兼容性尚待验证。

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

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):

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

上游原文 · 9506e1bd5c1f · Copyright (c) 2023–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL 许可证。

中文译校:PGSTY 社区。

PG.CENTER 双语底本