PostgreSQL 序列绑定字段与不绑定字段的区别解析

这篇文章主要介绍了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=#
【声明】:芜湖站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

相关文章