Author: Asineth MartinLast Updated: Wed, Aug 11, 2021
PostgreSQL is one of the most advanced open source Relational Database Management Systems (RDBMS). It is ANSI SQL:2008 standards compliant and has gained more buzz lately due to its addition of JSON and JSONB native data types, causing it to be looked at as a viable solution to problems NoSQL databases, such as MongoDB, are traditionally used to solve.
Follow this guide to install PostgreSql on CentOS 7.
Add the PostgreSQL repository.
$ sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
$ sudo yum install -y postgresql13-server
Initialize the database.
$ sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
Enable and start the service.
$ sudo systemctl enable --now postgresql-13
PostgreSQL creates a default user to access the
Switch to the user and execute a shell.
$ sudo -iu postgres psql
Create a database named
$ CREATE DATABASE test;
Connect to the new database named
$ \c test
Create a table named
$ CREATE TABLE messages (handle VARCHAR(32), message VARCHAR(280));
Insert a couple rows into the new table named
$ INSERT INTO messages VALUES ('User', 'This is a test message.'); $ INSERT INTO messages VALUES ('User', 'This is another test message.');
Query all rows from the table named
$ SELECT * FROM messages;
The rows inserted in the earlier steps should be listed.
PostgreSQL has many features that are available for use. Some of them include multi-version concurrency control (MVCC), point in time recovery, tablespaces, asynchronous replication, nested transactions (savepoints), online/hot backups, query planner/optimizer, and write ahead logging for fault tolerance. To get the most out of PostgreSQL, refer to the documentation.