99re6这里有精品热视频,久久综合九色欧美综合狠狠,国产精品久久久久久无毒不卡,av免费无插件在线观看,欧美放荡办公室videos

當前位置:首頁 >  站長 >  數(shù)據(jù)庫 >  正文

PostgreSQL 序列綁定字段與不綁定字段的區(qū)別說明

 2021-04-30 16:22  來源: 腳本之家   我來投稿 撤稿糾錯

  阿里云優(yōu)惠券 先領券再下單

這篇文章主要介紹了PostgreSQL 序列綁定字段與不綁定字段的區(qū)別說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

序列綁定字段與不綁定字段的區(qū)別

綁定字段

構(gòu)造數(shù)據(jù)

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=#

 

不綁定字段

構(gòu)造數(shù)據(jù)

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=#

總結(jié)

序列綁定字段,則刪除表的時候,序列會被一并刪除

序列不綁定字段,則序列與表是獨立的,刪除表不會將序列一并刪除

補充:PG表中字段使用序列類型以及綁定序列實例

兩種方法效果是一樣的

直接看代碼

文章來源:腳本之家

來源地址:https://www.jb51.net/article/205199.htm

申請創(chuàng)業(yè)報道,分享創(chuàng)業(yè)好點子。點擊此處,共同探討創(chuàng)業(yè)新機遇!

相關文章

熱門排行

信息推薦