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.
−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
About the Author
12+ years of rich experience on Database Administrations and on Infrastructure Solution Architect.
AWS Certified Solution Architect and Senior Oracle DBA
treatment for dry mucous membranes smelly gas while taking medication drugs to induce flatulence
Your comment is awaiting moderation.