溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

PG 13提供的force選項有什么作用

發布時間:2021-11-08 14:20:27 來源:億速云 閱讀:183 作者:iii 欄目:關系型數據庫

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

在PG 12或以下版本,刪除數據庫時如存在連接則無法刪除,PG 13提供了force選項,可終止相關連接直接刪除數據庫。

PG 12
創建數據庫并連接

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

刪除數據庫,一直在等待,超時后提示

[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
創建數據庫并連接

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

刪除數據庫,提示無法刪除數據庫

[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選項刪除

[local:/run/pg13]:5130 pg13@masterdb=# drop database dropdb with(force);
DROP DATABASE
[local:/run/pg13]:5130 pg13@masterdb=#

回到連接dropdb數據庫的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選項有什么作用”的內容了,經過本文的學習后,相信大家對PG 13提供的force選項有什么作用這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女