PostgreSQL is a powerful, open source object-relational database system ( ORDBMS ). Unlike other relational database systems, PostgreSQL allows users to create unique operators, complex data types, aggregate functions, data type conversion character, and other various database objects through the SQL function.

In this article, we are going to show you how to install PostgreSQL 10 database on CentOS 7 / RHEL 7. The latest stable release PostgreSQL 10 includes such enhancements as

Logical replication using publish/subscribe

Declarative table partitioning

Improved query parallelism

Significant general performance improvements

Stronger password authentication based on SCRAM-SHA-256

Improved monitoring and control





Step 1: Add the PostgreSQL 10 Repository

# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y

Step 2: Install PostgreSQL 10

# yum install postgresql10 postgresql10-server postgresql10-contrib postgresql10-libs -y

Step 3: Start PostgreSQL

– Initialize PostgreSQL:

# /usr/pgsql-10/bin/postgresql-10-setup initdb Initializing database ... OK

– Start/Enable PostgreSQL:

# systemctl enable postgresql-10.service # systemctl start postgresql-10.service

Step 4: Accessing Database

– Switch into the postgres user:

# su – postgres

– Connect to the PostgreSQL terminal:

# psql

Step 5: Usage Examples

– List all the databases:

# \list

– Connect to a database:

# \c database_name

– List all the tables

# \d

– Create a Database

# createdb database_name # createdb database_name OWNER rolename;

– Create a table

# create table employees (name varchar(25), surname varchar(25));

– Insert records

# INSERT INTO employees VALUES ('Lotfi','waderni');

– Exit from PosgreSQL prompt:

# \q



We hope this tutorial was enough Helpful. If you need more information, or have any questions, just comment below and we will be glad to assist you!



