Skip to content

Commit 8a6db4d

Browse files
authored
Create Set-Database-From-Single-User-Mode-to-Multi-User-Mode-PostgreSQL.sql
1 parent 314c426 commit 8a6db4d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--Terminating all active connections except the current session
2+
SELECT pg_terminate_backend(pid)
3+
FROM pg_stat_activity
4+
WHERE datname = 'University' AND pid <> pg_backend_pid();
5+
6+
7+
--Limiting database to allow only one connection (single-user mode)
8+
ALTER DATABASE University WITH CONNECTION LIMIT 1;
9+
10+
-- Reverting database to allow multiple connections (multi-user mode)
11+
ALTER DATABASE University WITH CONNECTION LIMIT -1;

0 commit comments

Comments
 (0)