software:postgresql
Spis treści
PostgreSQL
Tworzenie bazy i użytkownika
CREATE DATABASE dbname; CREATE USER username WITH PASSWORD 'user_password'; GRANT ALL PRIVILEGES ON DATABASE "dbname" to username;
Dodatkowo dla PostgreSQL 15.x i nowszych:
ALTER DATABASE dbname OWNER TO username;
Źródło: https://stackoverflow.com/questions/74110708/postgres-15-permission-denied-for-schema-public
Killowanie połączeń do bazy
PostgreSQL 9.2 i nowsze:
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB' AND pid <> pg_backend_pid();
PostgreSQL 9.1 i starsze:
SELECT pg_terminate_backend(pg_stat_activity.procpid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB' AND procpid <> pg_backend_pid();
Przeładowanie konfiguracji
Dwie metody:
sudo -u postgres -i pg_ctl reload
sudo -u postgres -i psql SELECT pg_reload_conf();
Źródło: https://www.heatware.net/databases/postgresql-reload-config-without-restarting/
software/postgresql.txt · ostatnio zmienione: 2023/07/17 00:44 przez mky