Site icon installvirtual

How to create database in postgres – postgres tutorial

Create database in postgres

In this tutorial in will show you how to create database in postgres command line.

PostgreSQL is a powerful, open source object-relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness. It runs on all major operating systems, including Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, Mac OS X, Solaris, Tru64), and Windows. It is fully ACID compliant, has full support for foreign keys, joins, views, triggers, and stored procedures (in multiple languages). It includes most SQL:2008 data types, including INTEGER, NUMERIC, BOOLEAN, CHAR, VARCHAR, DATE, INTERVAL, and TIMESTAMP. It also supports storage of binary large objects, including pictures, sounds, or video. It has native programming interfaces for C/C++, Java, .Net, Perl, Python, Ruby, Tcl, ODBC, among others, and exceptional documentation.

Read Also: How to install postgresql 9.6 on centos 7
Read Also: Install postgres  on mac using postgres app
Read Also: How to install postgresql 9.6 on Ubuntu

Create database in postgres

Now I will show you how to create database in postgres from command line. You just need to login into postgres database and execute the following command and don’t forgot to change database name.

postgres=# CREATE DATABASE installvirtual;
CREATE DATABASE

Change Ownership in postgres

We had created database now we need to change the ownership of the database. Let’s change the

postgres=# ALTER DATABASE installvirtual OWNER TO installvirtual;
ALTER DATABASE

So we have successfully created database and changed the ownership.

List Database in postgres

You can list the databases with the following command:

postgres=# \l
List of databases
Name           | Owner          | Encoding | Collate     | Ctype       | Access privileges
----------------+----------------+----------+-------------+-------------+-----------------------
installvirtual | installvirtual | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
postgres       | postgres       | UTF8     | en_US.UTF-8 | en_US.UTF-8 |

Read Also: Install pghero on centos 7

Exit mobile version