PostgreSQL: Create schema in specific database PostgreSQL: Create schema in specific database database database

PostgreSQL: Create schema in specific database


You can connect to the database, and execute the "CREATE SCHEMA" statement. That should result in a new schema in that database. It's not as tough as you think ;) When you want to do this from a .SQL file instead, you can use the \connect command as such:

 CREATE DATABASE foo; \connect foo; CREATE SCHEMA yourschema;


Login to New-Database with new user:

postgres=> \connect newdb user1...You are now connected to database "newdb" as user "user1".newdb=> 

To create schema with new user "user1" in newdb:

newdb=> CREATE SCHEMA s1;

To list the schema :

SELECT * from information_schema.schemata;