這篇文章給大家分享的是有關PostgreSQL 序列綁定字段與不綁定字段的區(qū)別有哪些的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
序列綁定字段與不綁定字段的區(qū)別
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表中字段使用序列類型以及綁定序列實例
兩種方法效果是一樣的
直接看代碼
感謝各位的閱讀!關于“PostgreSQL 序列綁定字段與不綁定字段的區(qū)別有哪些”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!