Skip to content

Instantly share code, notes, and snippets.

@noherczeg
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save noherczeg/0a27be2ae942743df3a6 to your computer and use it in GitHub Desktop.

Select an option

Save noherczeg/0a27be2ae942743df3a6 to your computer and use it in GitHub Desktop.
postgres database and schema creation
su - postgres
psql
CREATE ROLE stash WITH LOGIN PASSWORD 'stash' VALID UNTIL 'infinity';
CREATE DATABASE stash WITH ENCODING='UTF8' OWNER=stash CONNECTION LIMIT=-1;
\connect stash;
CREATE SCHEMA stash AUTHORIZATION stash;
ALTER USER stash SET SEARCH_PATH TO stash;
@noherczeg
Copy link
Author

Kill all sessions except current:

SELECT pg_terminate_backend(pid) FROM pg_stat_get_activity(NULL::integer) WHERE datid=(SELECT oid from pg_database where datname = 'stash');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment