How to create database in postgresql
Create Database command can be used to create a database in a cluster.
−Syntax:
Creating Databases
CREATE DATABASE name [ [ WITH ] [ OWNER [=] dbowner][ TEMPLATE [=] template ][ ENCODING [=] encoding ][ TABLESPACE [=] tablespace][ CONNECTION LIMIT [=] connlimit ] ]
1.Create database in postgresql named prod with user as enterprisedb.Please note enterprisedb is OS user as well.
edb=# create database prod owner enterprisedb;
CREATE DATABASE
2.Connect to newly created database in postgresql.
edb=# \connect prod
You are now connected to database "prod" as user "enterprisedb".
3.Please check whether you can see newly created database
prod=# select datname from pg_database;
datname
-----------
postgres
edb
template1
template0
prod
(5 rows)
prod=# exit
Related