PostgreSQLシーケンスバインディングフィールドと非バインディングフィールドの違いについて説明します。


シーケンスバインディングフィールドと非バインディングフィールドの違い
結合フィールド
データを作成

drop sequence if exists test_id_seq;
create sequence test_id_seq;
drop table if exists test;
create table test(id int default nextval('test_id_seq'), name text);
alter sequence test_id_seq owned by test.id;
テスト

test=# drop table test;
DROP TABLE
test=# \d
Did not find any relations.
test=# 
非結合フィールド
データを作成

drop sequence if exists test_id_seq;
create sequence test_id_seq;
drop table if exists test;
create table test(id int default nextval('test_id_seq'), name text);
テスト

test=# drop table test;
DROP TABLE
test=# \d
       List of relations
 Schema |  Name   |  Type  | Owner  
--------+-------------+----------+----------
 public | test_id_seq | sequence | postgres
(1 row)

test=# 
締め括りをつける
シーケンスバインディングフィールドは、テーブルを削除すると、シーケンスは一括して削除されます。
シーケンスがフィールドをバインディングしない場合、シーケンスはテーブルと独立しています。削除テーブルはシーケンスを一緒に削除しません。
補足:PGテーブルのフィールドは、シーケンスタイプとバインディングシーケンスの例を使用します。
二つの方法の効果は同じです。
コードを直接見る







以上は個人の経験ですので、参考にしていただければと思います。間違いがあったり、完全に考えていないところがあれば、教えてください。