這篇文章主要講解了“PG 13提供的force選項(xiàng)有什么作用”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“PG 13提供的force選項(xiàng)有什么作用”吧!
網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了翁牛特免費(fèi)建站歡迎大家使用!
在PG 12或以下版本,刪除數(shù)據(jù)庫(kù)時(shí)如存在連接則無(wú)法刪除,PG 13提供了force選項(xiàng),可終止相關(guān)連接直接刪除數(shù)據(jù)庫(kù)。
PG 12
創(chuàng)建數(shù)據(jù)庫(kù)并連接
[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ù)庫(kù),一直在等待,超時(shí)后提示
[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ù)庫(kù)并連接
[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ù)庫(kù),提示無(wú)法刪除數(shù)據(jù)庫(kù)
[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ù)庫(kù)的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)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)PG 13提供的force選項(xiàng)有什么作用這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
網(wǎng)頁(yè)題目:PG13提供的force選項(xiàng)有什么作用
鏈接分享:http://aaarwkj.com/article28/pdeccp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開(kāi)發(fā)、用戶體驗(yàn)、網(wǎng)站營(yíng)銷、服務(wù)器托管、網(wǎng)站收錄、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)