这篇文章主要介绍了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表中字段使用序列类型以及绑定序列实例
两种方法效果是一样的
直接看代码

文章插图

文章插图

文章插图

文章插图

文章插图

文章插图

文章插图
文章来源:脚本之家
来源地址:https://www.jb51.net/article/205199.htm
【PostgreSQL 序列绑定字段与不绑定字段的区别说明】申请创业报道,分享创业好点子 。,共同探讨创业新机遇!
- 美团绑定银行卡优惠就只有一次吗
- 苹果序列号f开头什么意思
- 没绑定手机号的微信会消失吗
- 苹果序列号j开头的是哪里产的
- 苹果手机序列号g开头是什么意思
- 抖音绑定银行有风险吗
- 为什么丹尼斯会员绑定车牌绑定不了
- 同花顺怎么解除绑定
- 可以查别人的微信聊天记录吗 怎么查qq绑定哪个微信聊天记录
- 怎么查询别人聊天记录 怎么查qq是否绑定微信聊天记录
特别声明:本站内容均来自网友提供或互联网,仅供参考,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
