Last active
August 29, 2015 14:17
-
-
Save noherczeg/0a27be2ae942743df3a6 to your computer and use it in GitHub Desktop.
postgres database and schema creation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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');