PostgreSQL DBA part 4 :-How to create database in postgresql

How to create database in postgresql

Create Database command can be used to create a database in a cluster.
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;

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;
(5 rows)

prod=# exit

Tags :

About the Author

debasis maity

12+ years of rich experience on Database Administrations and on Infrastructure Solution Architect. AWS Certified Solution Architect and Senior Oracle DBA

0 thoughts on “PostgreSQL DBA part 4 :-How to create database in postgresql

Leave a Reply

Your email address will not be published. Required fields are marked *