| 92 | |
| 93 | == Zamykanie połączeń do bazy danych == |
| 94 | Jeżeli chcemy usunąć bazę danych, a istnieją połączenia do bazy, to należy je zamknąć. |
| 95 | Dla PostgreSQL w wersji < 9.2 |
| 96 | {{{ |
| 97 | #!sql |
| 98 | SELECT pg_terminate_backend(pg_stat_activity.procpid) |
| 99 | FROM pg_stat_activity |
| 100 | WHERE pg_stat_activity.datname = 'TARGET_DB' |
| 101 | AND procpid <> pg_backend_pid(); |
| 102 | }}} |
| 103 | Dla wersji >= 9.2 |
| 104 | {{{ |
| 105 | #!sql |
| 106 | SELECT pg_terminate_backend(pg_stat_activity.pid) |
| 107 | FROM pg_stat_activity |
| 108 | WHERE pg_stat_activity.datname = 'TARGET_DB' |
| 109 | AND pid <> pg_backend_pid(); |
| 110 | }}} |