Skip to content

Instantly share code, notes, and snippets.

@gsilos
Last active January 3, 2019 19:34
Show Gist options
  • Save gsilos/f175cac8a3a353a5dab4aff71c0ebff4 to your computer and use it in GitHub Desktop.
Save gsilos/f175cac8a3a353a5dab4aff71c0ebff4 to your computer and use it in GitHub Desktop.
postgresql user db table setup
CREATE USER meuusuario WITH PASSWORD 'a';
CREATE DATABASE meudatabase;
GRANT ALL PRIVILEGES ON DATABASE meudatabase TO meuusuario;
\connect meudatabase
CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
CREATE TABLE minhatabela (
tabela_a bigint NOT NULL,
tabela_b hstore
);
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO meuusuario;
$ psql --host=instancia.rds.amazonaws.com -d postgres -U admin -a -f setup.sql
CREATE USER meuusuario WITH PASSWORD 'a';
CREATE ROLE
CREATE DATABASE meudatabase;
CREATE DATABASE
GRANT ALL PRIVILEGES ON DATABASE meudatabase TO meuusuario;
GRANT
\connect meudatabase
psql (9.5.12, server 9.5.12)
SSL connection (cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256)
You are now connected to database "meudatabase" as user "admin".
CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
CREATE EXTENSION
CREATE TABLE minhatabela (
tabela_a bigint NOT NULL,
tabela_b hstore
);
CREATE TABLE
GRANT
$ psql --host=instancia.rds.amazonaws.com -d meudatabase -U meuusuario -W
meudatabase=> \dt
List of relations
Schema | Name | Type | Owner
--------+-------------+-------+-------------
public | minhatabela | table | admin
meudatabase=> select * from minhatabela;
tabela_a | tabela_b
----------+----------
(0 rows)
meudatabase=> \q
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment