這篇文章主要講解了“PG 13提供的force選項(xiàng)有什么作用”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“PG 13提供的force選項(xiàng)有什么作用”吧!

在PG 12或以下版本,刪除數(shù)據(jù)庫時如存在連接則無法刪除,PG 13提供了force選項(xiàng),可終止相關(guān)連接直接刪除數(shù)據(jù)庫。
PG 12
創(chuàng)建數(shù)據(jù)庫并連接
[pg12@localhost ~]$ createdb dropdb [pg12@localhost ~]$ [pg12@localhost ~]$ psql -d dropdb Expanded display is used automatically. psql (12.1) Type "help" for help. [local:/run/pg12]:5120 pg12@dropdb=#
刪除數(shù)據(jù)庫,一直在等待,超時后提示
[pg12@localhost ~]$ psql Expanded display is used automatically. psql (12.1) Type "help" for help. [local:/run/pg12]:5120 pg12@testdb=# drop database dropdb; ERROR: database "dropdb" is being accessed by other users DETAIL: There is 1 other session using the database.
PG 13
創(chuàng)建數(shù)據(jù)庫并連接
[pg13@localhost ~]$ createdb dropdb [pg13@localhost ~]$ psql -d dropdb Expanded display is used automatically. psql (13devel) Type "help" for help. [local:/run/pg13]:5130 pg13@dropdb=#
刪除數(shù)據(jù)庫,提示無法刪除數(shù)據(jù)庫
[pg13@localhost ~]$ psql Expanded display is used automatically. psql (13devel) Type "help" for help. [local:/run/pg13]:5130 pg13@masterdb=# drop database dropdb; ERROR: database "dropdb" is being accessed by other users DETAIL: There is 1 other session using the database. [local:/run/pg13]:5130 pg13@masterdb=#
使用force選項(xiàng)刪除
[local:/run/pg13]:5130 pg13@masterdb=# drop database dropdb with(force); DROP DATABASE [local:/run/pg13]:5130 pg13@masterdb=#
回到連接dropdb數(shù)據(jù)庫的session,該session已被drop
[local:/run/pg13]:5130 pg13@dropdb=# select 1; FATAL: terminating connection due to administrator command server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Failed. : @!>?
感謝各位的閱讀,以上就是“PG 13提供的force選項(xiàng)有什么作用”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對PG 13提供的force選項(xiàng)有什么作用這一問題有了更深刻的體會,具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!
分享文章:PG13提供的force選項(xiàng)有什么作用-創(chuàng)新互聯(lián)
鏈接地址:http://chinadenli.net/article16/gshgg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站維護(hù)、網(wǎng)站制作、企業(yè)建站、App設(shè)計、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容