0

I am trying to launch a postgres db in a container. Below script is only creating database but not beyond that. PLease suggest what is wrong.

CREATE DATABASE mydb;

CREATE USER mydb;

ALTER DATABASE mydb owner to mydb;

GRANT ALL PRIVILEGES ON DATABASE mydb TO mydb;

GRANT CONNECT ON DATABASE mydb to mydb;


CREATE SCHEMA mydb.mydb ;
          

ALTER SCHEMA my_db.mydb  owner to mydb;



GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA mydb.mydb  TO mydb ;





CREATE TABLE mydb.applist
(
    "APPLICATION_ID" character varying(60) COLLATE pg_catalog."default" NOT NULL,
    "APPLICATION_NAME" character varying(200) COLLATE pg_catalog."default",
    
)
WITH (
    OIDS = FALSE
)
TABLESPACE pg_default;

Suggest corrections. Schema and tables aren't getting created.

Ranjith
  • 167
  • 1
  • 2
  • 15
  • You need to switch to the newly created database. Before you can create tables or schema in there. If that is run via `psql` use `\connect mydb` to [switch the database](https://stackoverflow.com/questions/3949876), then run `create schema my_schema;` (btw: I find using the name `mydb` for user, database **and** schema quite confusing) –  Sep 04 '20 at 09:01
  • I am trying to do this via a .sql file by copying it to docker-initdb. – Ranjith Sep 04 '20 at 09:03

0 Answers0